diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-02 11:54:28 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-02 11:54:28 (GMT) |
commit | 9a2b26748b73d604d1ec099d07e493b1ed8f020f (patch) | |
tree | 506fc381408c04c1d1037686f6972a31ab221458 /Lib/test/test_re.py | |
parent | 17485bf6f93034003555456810cdaaae6eac6eee (diff) | |
parent | 43fb54cd4f27f9c27f114d7b6fb2e04b35441a92 (diff) | |
download | cpython-9a2b26748b73d604d1ec099d07e493b1ed8f020f.zip cpython-9a2b26748b73d604d1ec099d07e493b1ed8f020f.tar.gz cpython-9a2b26748b73d604d1ec099d07e493b1ed8f020f.tar.bz2 |
Issue #10182: The re module doesn't truncate indices to 32 bits anymore.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r-- | Lib/test/test_re.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 19cfa04..82179b7 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,4 +1,4 @@ -from test.support import verbose, run_unittest, gc_collect +from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G import io import re from re import Scanner @@ -949,6 +949,21 @@ class ReTests(unittest.TestCase): # Test behaviour when not given a string or pattern as parameter self.assertRaises(TypeError, re.compile, 0) + # The huge memuse is because of re.sub() using a list and a join() + # to create the replacement result. + @bigmemtest(size=_2G, memuse=20) + def test_large(self, size): + # Issue #10182: indices were 32-bit-truncated. + s = 'a' * size + m = re.search('$', s) + self.assertIsNotNone(m) + self.assertEqual(m.start(), size) + self.assertEqual(m.end(), size) + r, n = re.subn('', '', s) + self.assertEqual(r, s) + self.assertEqual(n, size + 1) + + def run_re_tests(): from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR if verbose: |