]> granicus.if.org Git - python/commitdiff
SF bug #473525 pyclbr broken
authorTim Peters <tim.peters@gmail.com>
Wed, 24 Oct 2001 20:22:40 +0000 (20:22 +0000)
committerTim Peters <tim.peters@gmail.com>
Wed, 24 Oct 2001 20:22:40 +0000 (20:22 +0000)
As the comments in the module implied, pyclbr was easily confused by
"strange stuff" inside single- (but not triple-) quoted strings.  It
isn't anymore.  Its behavior remains flaky in the presence of nested
functions and classes, though.
Bugfix candidate.

Lib/pyclbr.py

index 95479a72a46096a4489cc533c4563e324331a39d..31fad46219b8f2b6c483efa29ae5767e8fd8b607 100644 (file)
@@ -29,11 +29,8 @@ are recognized and imported modules are scanned as well, this
 shouldn't happen often.
 
 BUGS
-- Continuation lines are not dealt with at all.
-- While triple-quoted strings won't confuse it, lines that look like
-  def, class, import or "from ... import" stmts inside backslash-continued
-  single-quoted strings are treated like code.  The expense of stopping
-  that isn't worth it.
+- Continuation lines are not dealt with at all, except inside strings.
+- Nested classes and functions can confuse it.
 - Code that doesn't pass tabnanny or python -t will confuse it, unless
   you set the module TABWIDTH vrbl (default 8) to the correct tab width
   for the file.
@@ -75,6 +72,10 @@ _getnext = re.compile(r"""
                         [^'\\]*
                     )*
         '''
+
+    |   " [^"\\\n]* (?: \\. [^"\\\n]*)* "
+
+    |   ' [^'\\\n]* (?: \\. [^'\\\n]*)* '
     )
 
 |   (?P<Method>