Fixed too ambitious "nothing to repeat" check. Closes bug #114033.
This commit is contained in:
parent
5c0b43d1e2
commit
13ac9926ac
|
@ -222,7 +222,7 @@ def _optimize_charset(charset, fixup):
|
||||||
def _simple(av):
|
def _simple(av):
|
||||||
# check if av is a "simple" operator
|
# check if av is a "simple" operator
|
||||||
lo, hi = av[2].getwidth()
|
lo, hi = av[2].getwidth()
|
||||||
if lo == 0:
|
if lo == 0 and hi == MAXREPEAT:
|
||||||
raise error, "nothing to repeat"
|
raise error, "nothing to repeat"
|
||||||
return lo == hi == 1 and av[2][0][0] != SUBPATTERN
|
return lo == hi == 1 and av[2][0][0] != SUBPATTERN
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
# See the sre.py file for information on usage and redistribution.
|
# See the sre.py file for information on usage and redistribution.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
MAXREPEAT = 65535
|
||||||
|
|
||||||
# should this really be here?
|
# should this really be here?
|
||||||
|
|
||||||
class error(Exception):
|
class error(Exception):
|
||||||
|
|
|
@ -12,8 +12,6 @@ import string, sys
|
||||||
|
|
||||||
from sre_constants import *
|
from sre_constants import *
|
||||||
|
|
||||||
MAXREPEAT = 65535
|
|
||||||
|
|
||||||
SPECIAL_CHARS = ".\\[{()*+?^$|"
|
SPECIAL_CHARS = ".\\[{()*+?^$|"
|
||||||
REPEAT_CHARS = "*+?{"
|
REPEAT_CHARS = "*+?{"
|
||||||
|
|
||||||
|
|
|
@ -615,10 +615,13 @@ xyzabc
|
||||||
# bug 112468: various expected syntax errors
|
# bug 112468: various expected syntax errors
|
||||||
('(', '', SYNTAX_ERROR),
|
('(', '', SYNTAX_ERROR),
|
||||||
('[\\41]', '!', SUCCEED, 'found', '!'),
|
('[\\41]', '!', SUCCEED, 'found', '!'),
|
||||||
|
# bug 114033: nothing to repeat
|
||||||
|
(r'(x?)?', 'x', SUCCEED, 'found', 'x'),
|
||||||
# bug 115040: rescan if flags are modified inside pattern
|
# bug 115040: rescan if flags are modified inside pattern
|
||||||
(r' (?x)foo ', 'foo', SUCCEED, 'found', 'foo'),
|
(r' (?x)foo ', 'foo', SUCCEED, 'found', 'foo'),
|
||||||
# bug 115618: negative lookahead
|
# bug 115618: negative lookahead
|
||||||
(r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'),
|
(r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'),
|
||||||
# bug 116251: character class bug
|
# bug 116251: character class bug
|
||||||
(r'[\w-]+', 'laser_beam', SUCCEED, 'found', 'laser_beam'),
|
(r'[\w-]+', 'laser_beam', SUCCEED, 'found', 'laser_beam'),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue