diff options
author | Fredrik Lundh <fredrik@pythonware.com> | 2001-02-18 21:04:48 +0000 |
---|---|---|
committer | Fredrik Lundh <fredrik@pythonware.com> | 2001-02-18 21:04:48 +0000 |
commit | 1344b6cbaba4a4ea428be9031b9f9d845ccf5a97 (patch) | |
tree | 74d6342b9fa124227cd2d918b2ef46801ae955ae /Lib | |
parent | a3b791d9ff1c7d450aaefef6ca0f80f1c1340651 (diff) | |
download | cpython-1344b6cbaba4a4ea428be9031b9f9d845ccf5a97.tar.gz |
detect attempts to repeat anchors (fixes bug #130748)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/sre_parse.py | 3 | ||||
-rwxr-xr-x | Lib/test/re_tests.py | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 36036b6ecb..3840365b8e 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -446,6 +446,7 @@ def _parse(source, state): min, max = 0, 1 elif this == "*": min, max = 0, MAXREPEAT + elif this == "+": min, max = 1, MAXREPEAT elif this == "{": @@ -475,6 +476,8 @@ def _parse(source, state): if subpattern: item = subpattern[-1:] else: + item = None + if not item or (len(item) == 1 and item[0][0] == AT): raise error, "nothing to repeat" if item[0][0] in (MIN_REPEAT, MAX_REPEAT): raise error, "multiple repeat" diff --git a/Lib/test/re_tests.py b/Lib/test/re_tests.py index 9daf8c4cde..aacd916267 100755 --- a/Lib/test/re_tests.py +++ b/Lib/test/re_tests.py @@ -636,4 +636,6 @@ xyzabc (r'(?i)m+', 'MMM', SUCCEED, 'found', 'MMM'), (r'(?i)[M]+', 'MMM', SUCCEED, 'found', 'MMM'), (r'(?i)[m]+', 'MMM', SUCCEED, 'found', 'MMM'), + # bug 130748: ^* should be an error (nothing to repeat) + (r'^*', '', SYNTAX_ERROR), ] |