]> granicus.if.org Git - python/commitdiff
Recompile pattern if (?x) flag was found inside the pattern during the
authorFredrik Lundh <fredrik@pythonware.com>
Tue, 3 Oct 2000 19:22:26 +0000 (19:22 +0000)
committerFredrik Lundh <fredrik@pythonware.com>
Tue, 3 Oct 2000 19:22:26 +0000 (19:22 +0000)
first scan.  Closes bug #115040.

Lib/sre_parse.py
Lib/test/re_tests.py

index f4741c9bd960709ad9f97672f0f8a19ddcb7fc74..fcf5bcc9fd0bc8cf1537202e9a81d160fff17e6b 100644 (file)
@@ -593,6 +593,11 @@ def parse(str, flags=0, pattern=None):
 
     # p.dump()
 
+    if not (flags & SRE_FLAG_VERBOSE) and p.pattern.flags & SRE_FLAG_VERBOSE:
+        # the VERBOSE flag was switched on inside the pattern.  to be
+        # on the safe side, we'll parse the whole thing again...
+        return parse(str, p.pattern.flags)
+
     return p
 
 def parse_template(source, pattern):
index bb72f3d5445ac45a3357681ac5027824586a9686..86752244b789bb4e41b68e2818b993373761f530 100755 (executable)
@@ -612,9 +612,11 @@ xyzabc
     (r'(([a-z]+):)?([a-z]+)$', 'smil', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-smil'),
     # bug 111869 (PRE/PCRE fails on this one, SRE doesn't)
     (r'.*d', 'abc\nabd', SUCCEED, 'found', 'abd'),
-    # bug 112468
+    # bug 112468: various expected syntax errors
     ('(', '', SYNTAX_ERROR),
     ('[\\41]', '!', SUCCEED, 'found', '!'),
-    # bug 115618
+    # bug 115040: rescan if flags are modified inside pattern
+    (r' (?x)foo ', 'foo', SUCCEED, 'found', 'foo'),
+    # bug 115618: negative lookahead
     (r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'),
 ]