[Python-checkins] cpython (3.3): Issue #2537: Remove breaked check which prevented valid regular expressions.
serhiy.storchaka
python-checkins at python.org
Mon Aug 19 22:30:33 CEST 2013
http://hg.python.org/cpython/rev/7ab07f15d78c
changeset: 85274:7ab07f15d78c
branch: 3.3
parent: 85271:19ed2fbb8e6b
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Aug 19 23:18:23 2013 +0300
summary:
Issue #2537: Remove breaked check which prevented valid regular expressions.
Patch by Meador Inge.
See also issue #18647.
files:
Lib/sre_compile.py | 2 --
Lib/test/test_re.py | 10 ++++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -358,8 +358,6 @@
def _simple(av):
# check if av is a "simple" operator
lo, hi = av[2].getwidth()
- #if lo == 0 and hi == MAXREPEAT:
- # raise error("nothing to repeat")
return lo == hi == 1 and av[2][0][0] != SUBPATTERN
def _compile_info(code, pattern, flags):
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1051,6 +1051,16 @@
[b'xyz'], msg=pattern)
+ def test_bug_2537(self):
+ # issue 2537: empty submatches
+ for outer_op in ('{0,}', '*', '+', '{1,187}'):
+ for inner_op in ('{0,}', '*', '?'):
+ r = re.compile("^((x|y)%s)%s" % (inner_op, outer_op))
+ m = r.match("xyyzy")
+ self.assertEqual(m.group(0), "xyy")
+ self.assertEqual(m.group(1), "")
+ self.assertEqual(m.group(2), "y")
+
def run_re_tests():
from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose:
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list