]> granicus.if.org Git - python/commitdiff
- don't hang if group id is followed by whitespace (closes bug #114660)
authorFredrik Lundh <fredrik@pythonware.com>
Sun, 24 Sep 2000 14:46:23 +0000 (14:46 +0000)
committerFredrik Lundh <fredrik@pythonware.com>
Sun, 24 Sep 2000 14:46:23 +0000 (14:46 +0000)
Lib/sre_parse.py
Lib/test/re_tests.py
Lib/test/test_sre.py

index 55de24c5c1bca50272812200f4cac030b47f62c4..f4741c9bd960709ad9f97672f0f8a19ddcb7fc74 100644 (file)
@@ -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
index 7eac04cb8f4ebcf74d2ccc81e0f0df99db939dc3..3a25d511afeea10b1238bf8b26b129b5a2124724 100755 (executable)
@@ -1,6 +1,5 @@
 #!/usr/bin/env python
 # -*- mode: python -*-
-# $Id$
 
 # Re test suite and benchmark suite v1.5
 
index d3e9dbe3674fb12387eebde2bfd9a091fb3dded2..373efa0a12eb04c86c37590a8f8df381f969d023 100644 (file)
@@ -114,6 +114,9 @@ test(r"""sre.sub(r'^\s*', 'X', 'test')""", 'Xtest')
 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'