Rev 5394: Handle test_source and extensions. Also define an 'extern' protocol, to allow in http://bazaar.launchpad.net/~jameinel/bzr/2.3-btree-chk-leaf

John Arbash Meinel john at arbash-meinel.com
Tue Aug 24 20:21:54 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.3-btree-chk-leaf

------------------------------------------------------------
revno: 5394
revision-id: john at arbash-meinel.com-20100824192132-2ktt5adkbk5bk1ct
parent: john at arbash-meinel.com-20100823213606-1pk5w1nyaz9kz9k0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-btree-chk-leaf
timestamp: Tue 2010-08-24 14:21:32 -0500
message:
  Handle test_source and extensions. Also define an 'extern' protocol, to allow
  the test suite to recognize that returning an object of that type is a Python object.
-------------- next part --------------
=== modified file 'bzrlib/_btree_serializer_pyx.pyx'
--- a/bzrlib/_btree_serializer_pyx.pyx	2010-08-23 21:36:06 +0000
+++ b/bzrlib/_btree_serializer_pyx.pyx	2010-08-24 19:21:32 +0000
@@ -64,12 +64,16 @@
     unsigned long strtoul(char *s1, char **out, int base)
     long long strtoll(char *s1, char **out, int base)
 
+
 # It seems we need to import the definitions so that the pyrex compiler has
 # local names to access them.
 from _static_tuple_c cimport StaticTuple, \
     import_static_tuple_c, StaticTuple_New, \
     StaticTuple_Intern, StaticTuple_SET_ITEM, StaticTuple_CheckExact, \
     StaticTuple_GET_SIZE, StaticTuple_GET_ITEM
+# This tells the test infrastructure that StaticTuple is a class, so we don't
+# have to worry about exception checking.
+## extern cdef class StaticTuple
 import sys
 
 
@@ -112,7 +116,6 @@
     Py_DECREF_ptr(py_str)
     return result
 
-from bzrlib import _static_tuple_c
 # This sets up the StaticTuple C_API functionality
 import_static_tuple_c()
 
@@ -356,7 +359,7 @@
 _populate_unhexbuf()
 
 
-cdef int _unhexlify_sha1(char *as_hex, char *as_bin):
+cdef int _unhexlify_sha1(char *as_hex, char *as_bin): # cannot_raise
     """Take the hex sha1 in as_hex and make it binary in as_bin
     
     Same as binascii.unhexlify, but working on C strings, not Python objects.
@@ -390,7 +393,7 @@
     return None
 
 
-cdef void _hexlify_sha1(char *as_bin, char *as_hex):
+cdef void _hexlify_sha1(char *as_bin, char *as_hex): # cannot_raise
     cdef int i, j
     cdef char c
 
@@ -412,7 +415,7 @@
     return as_hex
 
 
-cdef int _key_to_sha1(key, char *sha1):
+cdef int _key_to_sha1(key, char *sha1): # cannot_raise
     """Map a key into its sha1 content.
 
     :param key: A tuple of style ('sha1:abcd...',)
@@ -483,7 +486,7 @@
     return _sha1_to_key(PyString_AS_STRING(sha1_bin))
 
 
-cdef unsigned int _sha1_to_uint(char *sha1):
+cdef unsigned int _sha1_to_uint(char *sha1): # cannot_raise
     cdef unsigned int val
     # Must be in MSB, because that is how the content is sorted
     val = (((<unsigned int>(sha1[0]) & 0xff) << 24)
@@ -692,7 +695,7 @@
             PyList_Append(result, item)
         return result
 
-    cdef int _count_records(self, char *c_content, char *c_end):
+    cdef int _count_records(self, char *c_content, char *c_end): # cannot_raise
         """Count how many records are in this section."""
         cdef char *c_cur
         cdef int num_records

=== modified file 'bzrlib/tests/test_source.py'
--- a/bzrlib/tests/test_source.py	2010-07-05 16:01:33 +0000
+++ b/bzrlib/tests/test_source.py	2010-08-24 19:21:32 +0000
@@ -388,8 +388,10 @@
         """
         both_exc_and_no_exc = []
         missing_except = []
-        class_re = re.compile(r'^(cdef\s+)?(public\s+)?(api\s+)?class (\w+).*:',
-                              re.MULTILINE)
+        class_re = re.compile(r'^(cdef\s+)?(public\s+)?'
+                              r'(api\s+)?class (\w+).*:', re.MULTILINE)
+        extern_class_re = re.compile(r'## extern cdef class (\w+)',
+                                     re.MULTILINE)
         except_re = re.compile(r'cdef\s+' # start with cdef
                                r'([\w *]*?)\s*' # this is the return signature
                                r'(\w+)\s*\(' # the function name
@@ -400,6 +402,7 @@
         for fname, text in self.get_source_file_contents(
                 extensions=('.pyx',)):
             known_classes = set([m[-1] for m in class_re.findall(text)])
+            known_classes.update(extern_class_re.findall(text))
             cdefs = except_re.findall(text)
             for sig, func, exc_clause, no_exc_comment in cdefs:
                 if sig.startswith('api '):



More information about the bazaar-commits mailing list