changeset: 85275:f4271cc2dfb5 parent: 85272:8b24818c7327 parent: 85274:7ab07f15d78c user: Serhiy Storchaka date: Mon Aug 19 23:19:49 2013 +0300 files: Lib/sre_compile.py description: Issue #2537: Remove breaked check which prevented valid regular expressions. Patch by Meador Inge. See also issue #18647. diff -r 8b24818c7327 -r f4271cc2dfb5 Lib/sre_compile.py --- a/Lib/sre_compile.py Mon Aug 19 23:04:33 2013 +0300 +++ b/Lib/sre_compile.py Mon Aug 19 23:19:49 2013 +0300 @@ -351,8 +351,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 -r 8b24818c7327 -r f4271cc2dfb5 Lib/test/test_re.py --- a/Lib/test/test_re.py Mon Aug 19 23:04:33 2013 +0300 +++ b/Lib/test/test_re.py Mon Aug 19 23:19:49 2013 +0300 @@ -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: