From: Anthony Baxter Date: Wed, 5 Dec 2001 05:56:02 +0000 (+0000) Subject: backport 1.23: X-Git-Tag: v2.1.2c1~64 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4bc57dea311b3540a216ae65abad491a23b88ffd;p=thirdparty%2FPython%2Fcpython.git backport 1.23: SF bug #473525 pyclbr broken 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. --- diff --git a/Lib/pyclbr.py b/Lib/pyclbr.py index c9bb2fe2bbb1..1dbba91b257c 100644 --- a/Lib/pyclbr.py +++ b/Lib/pyclbr.py @@ -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. @@ -76,6 +73,10 @@ _getnext = re.compile(r""" [^'\\]* )* ''' + + | " [^"\\\n]* (?: \\. [^"\\\n]*)* " + + | ' [^'\\\n]* (?: \\. [^'\\\n]*)* ' ) | (?P