diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 55de24c5c1b..f4741c9bd96 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -634,7 +634,7 @@ def parse_template(source, pattern): while 1: group = _group(this, pattern.groups+1) if group: - if (not s.next or + if (s.next not in DIGITS or not _group(this + s.next, pattern.groups+1)): code = MARK, int(group) break diff --git a/Lib/test/re_tests.py b/Lib/test/re_tests.py index 7eac04cb8f4..3a25d511afe 100755 --- a/Lib/test/re_tests.py +++ b/Lib/test/re_tests.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- mode: python -*- -# $Id$ # Re test suite and benchmark suite v1.5 diff --git a/Lib/test/test_sre.py b/Lib/test/test_sre.py index d3e9dbe3674..373efa0a12e 100644 --- a/Lib/test/test_sre.py +++ b/Lib/test/test_sre.py @@ -114,6 +114,9 @@ def bump_num(matchobj): test(r"""sre.sub(r'a', 'b', 'aaaaa')""", 'bbbbb') test(r"""sre.sub(r'a', 'b', 'aaaaa', 1)""", 'baaaa') +# bug 114660 +test(r"""sre.sub(r'(\S)\s+(\S)', r'\1 \2', 'hello there')""", 'hello there') + if verbose: print 'Running tests on symbolic references'