From: Tim Peters Date: Sat, 22 Nov 2003 03:25:40 +0000 (+0000) Subject: Reverted from rev 1.45.6.1 to rev 1.45: deep recursion is still part of X-Git-Tag: v2.3.3c1~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1b3d080cb621e773dd0adedfa841e47cb14a209;p=thirdparty%2FPython%2Fcpython.git Reverted from rev 1.45.6.1 to rev 1.45: deep recursion is still part of sre in 2.3, and the backport of the 2.4 version of the tests should not have been done. It got confused because someone else checked a bad change into _sre.c that caused the tests that are *supposed* to raise a recursion exception to stop doing so on some (most?) platforms. test_re passes again on Windows now. Until the bad change to _sre gets fixed, it will fail on platforms other than Windows and FreeBSD, either by "Test Failed", or by bad consequences of C stack overflow. --- diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 12564fa7fc37..f7248062a2ab 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -169,7 +169,7 @@ class ReTests(unittest.TestCase): self.assertEqual(pat.match('ac').group(1, 'b2', 3), ('a', None, 'c')) def test_re_groupref_exists(self): - return # not yet + return # not yet self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a)').groups(), ('(', 'a')) self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', 'a').groups(), @@ -405,21 +405,19 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match('.*?cd', 5000*'ab'+'c'+5000*'ab'+'cde').end(0), 20003) self.assertEqual(re.match('.*?cd', 20000*'abc'+'de').end(0), 60001) - # non-simple '*?' still used to hit the recursion limit, before the - # non-recursive scheme was implemented. - self.assertEqual(re.search('(a|b)*?c', 10000*'ab'+'cd').end(0), 20001) - + # non-simple '*?' still recurses and hits the recursion limit + self.assertRaises(RuntimeError, re.search, '(a|b)*?c', 10000*'ab'+'cd') def test_bug_612074(self): pat=u"["+re.escape(u"\u2039")+u"]" self.assertEqual(re.compile(pat) and 1, 1) def test_stack_overflow(self): - # nasty cases that used to overflow the straightforward recursive + # nasty case that overflows the straightforward recursive # implementation of repeated groups. - self.assertEqual(re.match('(x)*', 50000*'x').group(1), 'x') - self.assertEqual(re.match('(x)*y', 50000*'x'+'y').group(1), 'x') - self.assertEqual(re.match('(x)*?y', 50000*'x'+'y').group(1), 'x') + self.assertRaises(RuntimeError, re.match, '(x)*', 50000*'x') + self.assertRaises(RuntimeError, re.match, '(x)*y', 50000*'x'+'y') + self.assertRaises(RuntimeError, re.match, '(x)*?y', 50000*'x'+'y') def test_scanner(self): def s_ident(scanner, token): return token