]> granicus.if.org Git - python/commitdiff
Fixed too ambitious "nothing to repeat" check. Closes bug #114033.
authorFredrik Lundh <fredrik@pythonware.com>
Sat, 7 Oct 2000 17:38:23 +0000 (17:38 +0000)
committerFredrik Lundh <fredrik@pythonware.com>
Sat, 7 Oct 2000 17:38:23 +0000 (17:38 +0000)
Lib/sre_compile.py
Lib/sre_constants.py
Lib/sre_parse.py
Lib/test/re_tests.py

index 97a57e2db19cdf2db71604976fd6d786cf5d2173..dc508e57cdc4d1c1beab725feac59b17cc709cf8 100644 (file)
@@ -222,7 +222,7 @@ def _optimize_charset(charset, fixup):
 def _simple(av):
     # check if av is a "simple" operator
     lo, hi = av[2].getwidth()
-    if lo == 0:
+    if lo == 0 and hi == MAXREPEAT:
         raise error, "nothing to repeat"
     return lo == hi == 1 and av[2][0][0] != SUBPATTERN
 
index 5a20930ce1d51b73577d811e63a587c9e6b4dea6..ea649c048293dfc32949387693120911732c7655 100644 (file)
@@ -9,6 +9,8 @@
 # See the sre.py file for information on usage and redistribution.
 #
 
+MAXREPEAT = 65535
+
 # should this really be here?
 
 class error(Exception):
index 9cbbc0254e8647db64699ade1a3b0513e93f5bda..7c36d4f2dcb2bb673d34d333c1b03407c8954efb 100644 (file)
@@ -12,8 +12,6 @@ import string, sys
 
 from sre_constants import *
 
-MAXREPEAT = 65535
-
 SPECIAL_CHARS = ".\\[{()*+?^$|"
 REPEAT_CHARS = "*+?{"
 
index 7c541752f28fa42c5779a356885af45db4685f49..2d3155dacfef712f5b30d00161664164027a16ef 100755 (executable)
@@ -615,10 +615,13 @@ xyzabc
     # bug 112468: various expected syntax errors
     ('(', '', SYNTAX_ERROR),
     ('[\\41]', '!', SUCCEED, 'found', '!'),
+    # bug 114033: nothing to repeat
+    (r'(x?)?', 'x', SUCCEED, 'found', 'x'),
     # 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'),
     # bug 116251: character class bug
     (r'[\w-]+', 'laser_beam', SUCCEED, 'found', 'laser_beam'),
+
 ]