Skip to content

Commit 19f977b

Browse files
author
Fredrik Lundh
committed
- don't hang if group id is followed by whitespace (closes bug python#114660)
1 parent 96753b3 commit 19f977b

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Lib/sre_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def parse_template(source, pattern):
634634
while 1:
635635
group = _group(this, pattern.groups+1)
636636
if group:
637-
if (not s.next or
637+
if (s.next not in DIGITS or
638638
not _group(this + s.next, pattern.groups+1)):
639639
code = MARK, int(group)
640640
break

Lib/test/re_tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
# -*- mode: python -*-
3-
# $Id$
43

54
# Re test suite and benchmark suite v1.5
65

Lib/test/test_sre.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ def bump_num(matchobj):
114114
test(r"""sre.sub(r'a', 'b', 'aaaaa')""", 'bbbbb')
115115
test(r"""sre.sub(r'a', 'b', 'aaaaa', 1)""", 'baaaa')
116116

117+
# bug 114660
118+
test(r"""sre.sub(r'(\S)\s+(\S)', r'\1 \2', 'hello there')""", 'hello there')
119+
117120
if verbose:
118121
print 'Running tests on symbolic references'
119122

0 commit comments

Comments
 (0)