diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2006-01-31 18:34:13 (GMT) |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2006-01-31 18:34:13 (GMT) |
commit | 548148810bfb4f44450a93f98912a5eee07d4303 (patch) | |
tree | 88623393a45b07172e65a21e579f0dbd9f7f8cd6 /Lib/test/test_difflib.py | |
parent | c81e3a63af37630a49d1df6b4a52436aa1d6bf4e (diff) | |
download | cpython-548148810bfb4f44450a93f98912a5eee07d4303.zip cpython-548148810bfb4f44450a93f98912a5eee07d4303.tar.gz cpython-548148810bfb4f44450a93f98912a5eee07d4303.tar.bz2 |
Patch #1413711: Certain patterns of differences were making difflib
touch the recursion limit. The applied patch inlines the recursive
__helper method in a non-recursive way.
Diffstat (limited to 'Lib/test/test_difflib.py')
-rw-r--r-- | Lib/test/test_difflib.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py index c0bf66e..52feef0 100644 --- a/Lib/test/test_difflib.py +++ b/Lib/test/test_difflib.py @@ -2,6 +2,7 @@ import difflib from test.test_support import run_unittest, findfile import unittest import doctest +import sys class TestSFbugs(unittest.TestCase): @@ -143,6 +144,14 @@ class TestSFpatches(unittest.TestCase): self.assertEqual(actual,expect) + def test_recursion_limit(self): + # Check if the problem described in patch #1413711 exists. + limit = sys.getrecursionlimit() + old = [(i%2 and "K:%d" or "V:A:%d") % i for i in range(limit*2)] + new = [(i%2 and "K:%d" or "V:B:%d") % i for i in range(limit*2)] + difflib.SequenceMatcher(None, old, new).get_opcodes() + + Doctests = doctest.DocTestSuite(difflib) run_unittest(TestSFpatches, TestSFbugs, Doctests) |