Rev 4934: Clean up _simple_set.pyx, and handle 'nogil'. in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-pyrex-propagation

John Arbash Meinel john at arbash-meinel.com
Tue Jan 5 05:28:58 GMT 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-pyrex-propagation

------------------------------------------------------------
revno: 4934
revision-id: john at arbash-meinel.com-20100105052842-pegkjxr8pwec0ovn
parent: john at arbash-meinel.com-20100105050945-itxiesuol1op6usy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0rc1-pyrex-propagation
timestamp: Mon 2010-01-04 23:28:42 -0600
message:
  Clean up _simple_set.pyx, and handle 'nogil'.
  
  This took a bit more than I thought, as we had to start handling 'api'
  and 'public api' definitions. As well as 'nogil'.
  I'm a bit concerned that the regex is getting a bit complex, but it
  seems to be finding what I want it to.
-------------- next part --------------
=== modified file 'bzrlib/_simple_set_pyx.pxd'
--- a/bzrlib/_simple_set_pyx.pxd	2009-10-09 16:49:45 +0000
+++ b/bzrlib/_simple_set_pyx.pxd	2010-01-05 05:28:42 +0000
@@ -88,4 +88,4 @@
 cdef api int SimpleSet_Discard(object self, object key) except -1
 cdef api PyObject *SimpleSet_Get(SimpleSet self, object key) except? NULL
 cdef api Py_ssize_t SimpleSet_Size(object self) except -1
-cdef api int SimpleSet_Next(object self, Py_ssize_t *pos, PyObject **key)
+cdef api int SimpleSet_Next(object self, Py_ssize_t *pos, PyObject **key) except -1

=== modified file 'bzrlib/_simple_set_pyx.pyx'
--- a/bzrlib/_simple_set_pyx.pyx	2009-10-14 15:57:06 +0000
+++ b/bzrlib/_simple_set_pyx.pyx	2010-01-05 05:28:42 +0000
@@ -540,7 +540,8 @@
     return _check_self(self)._used
 
 
-cdef api int SimpleSet_Next(object self, Py_ssize_t *pos, PyObject **key):
+cdef api int SimpleSet_Next(object self, Py_ssize_t *pos,
+                            PyObject **key) except -1:
     """Walk over items in a SimpleSet.
 
     :param pos: should be initialized to 0 by the caller, and will be updated
@@ -567,7 +568,8 @@
     return 1
 
 
-cdef int SimpleSet_traverse(SimpleSet self, visitproc visit, void *arg):
+cdef int SimpleSet_traverse(SimpleSet self, visitproc visit,
+                            void *arg) except -1:
     """This is an implementation of 'tp_traverse' that hits the whole table.
 
     Cython/Pyrex don't seem to let you define a tp_traverse, and they only

=== modified file 'bzrlib/tests/test_source.py'
--- a/bzrlib/tests/test_source.py	2010-01-05 05:09:45 +0000
+++ b/bzrlib/tests/test_source.py	2010-01-05 05:28:42 +0000
@@ -382,8 +382,9 @@
         """
         both_exc_and_no_exc = []
         missing_except = []
-        class_re = re.compile(r'^(cdef\s+)?class (\w+).*:', re.MULTILINE)
-        except_re = re.compile(r'cdef\s*' # start with cdef
+        class_re = re.compile(r'^(cdef\s+)?(public\s+)?(api\s+)?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
                                r'[^)]*\)\s*' # parameters
@@ -392,11 +393,15 @@
                               )
         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 = set([m[-1] for m in class_re.findall(text)])
             cdefs = except_re.findall(text)
             for sig, func, exc_clause, no_exc_comment in cdefs:
+                if sig.startswith('api '):
+                    sig = sig[4:]
                 if not sig or sig in known_classes:
                     sig = 'object'
+                if 'nogil' in exc_clause:
+                    exc_clause = exc_clause.replace('nogil', '').strip()
                 if exc_clause and no_exc_comment:
                     both_exc_and_no_exc.append((fname, func))
                 if sig != 'object' and not (exc_clause or no_exc_comment):



More information about the bazaar-commits mailing list