summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-08-19 20:20:07 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-08-19 20:20:07 (GMT)
commit83737c632c9d12dc74074fc4884091bdfd2b15f0 (patch)
treec479d59a17631dca3f70b90d1693b6d1b8f64f87
parent0364134fc80f779381392ebe46d27dde909f0d1a (diff)
downloadcpython-83737c632c9d12dc74074fc4884091bdfd2b15f0.zip
cpython-83737c632c9d12dc74074fc4884091bdfd2b15f0.tar.gz
cpython-83737c632c9d12dc74074fc4884091bdfd2b15f0.tar.bz2
Issue #2537: Remove breaked check which prevented valid regular expressions.
Patch by Meador Inge. See also issue #18647.
-rw-r--r--Lib/sre_compile.py2
-rw-r--r--Lib/test/test_re.py10
2 files changed, 10 insertions, 2 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index 425a1f8..15d2324 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -355,8 +355,6 @@ def _optimize_unicode(charset, fixup):
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
index 2be5f5c..8b277cf 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -908,6 +908,16 @@ class ReTests(unittest.TestCase):
[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: