summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2004-09-03 18:11:59 (GMT)
committerGustavo Niemeyer <gustavo@niemeyer.net>2004-09-03 18:11:59 (GMT)
commit0506c64086e2535335a58b9368d2b940abbf8c11 (patch)
tree44cdb5b7978f1452156df79ed0b0bbf3b1f13fc8 /Lib
parenta01a2ee933238dbd3e79bc3b07cfb703d40807a8 (diff)
downloadcpython-0506c64086e2535335a58b9368d2b940abbf8c11.zip
cpython-0506c64086e2535335a58b9368d2b940abbf8c11.tar.gz
cpython-0506c64086e2535335a58b9368d2b940abbf8c11.tar.bz2
Fixing bug #817234, which made SRE get into an infinite loop on
empty final matches with finditer(). New test cases included for this bug and for #581080.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_re.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 8f66ae9..9e5fe0d 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -567,6 +567,22 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.compile(pattern).split("a.b.c"),
['a','b','c'])
+ def test_bug_581080(self):
+ iter = re.finditer(r"\s", "a b")
+ self.assertEqual(iter.next().span(), (1,2))
+ self.assertRaises(StopIteration, iter.next)
+
+ scanner = re.compile(r"\s").scanner("a b")
+ self.assertEqual(scanner.search().span(), (1, 2))
+ self.assertEqual(scanner.search(), None)
+
+ def test_bug_817234(self):
+ iter = re.finditer(r".*", "asdf")
+ self.assertEqual(iter.next().span(), (0, 4))
+ self.assertEqual(iter.next().span(), (4, 4))
+ self.assertRaises(StopIteration, iter.next)
+
+
def run_re_tests():
from test.re_tests import benchmarks, tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose: