~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_source.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-05 05:28:42 UTC
  • mto: This revision was merged to the branch mainline in revision 4936.
  • Revision ID: john@arbash-meinel.com-20100105052842-pegkjxr8pwec0ovn
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.

Show diffs side-by-side

added added

removed removed

Lines of Context:
382
382
        """
383
383
        both_exc_and_no_exc = []
384
384
        missing_except = []
385
 
        class_re = re.compile(r'^(cdef\s+)?class (\w+).*:', re.MULTILINE)
386
 
        except_re = re.compile(r'cdef\s*' # start with cdef
 
385
        class_re = re.compile(r'^(cdef\s+)?(public\s+)?(api\s+)?class (\w+).*:',
 
386
                              re.MULTILINE)
 
387
        except_re = re.compile(r'cdef\s+' # start with cdef
387
388
                               r'([\w *]*?)\s*' # this is the return signature
388
389
                               r'(\w+)\s*\(' # the function name
389
390
                               r'[^)]*\)\s*' # parameters
392
393
                              )
393
394
        for fname, text in self.get_source_file_contents(
394
395
                extensions=('.pyx',)):
395
 
            known_classes = set([m[1] for m in class_re.findall(text)])
 
396
            known_classes = set([m[-1] for m in class_re.findall(text)])
396
397
            cdefs = except_re.findall(text)
397
398
            for sig, func, exc_clause, no_exc_comment in cdefs:
 
399
                if sig.startswith('api '):
 
400
                    sig = sig[4:]
398
401
                if not sig or sig in known_classes:
399
402
                    sig = 'object'
 
403
                if 'nogil' in exc_clause:
 
404
                    exc_clause = exc_clause.replace('nogil', '').strip()
400
405
                if exc_clause and no_exc_comment:
401
406
                    both_exc_and_no_exc.append((fname, func))
402
407
                if sig != 'object' and not (exc_clause or no_exc_comment):