diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-02 11:52:36 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-12-02 11:52:36 (GMT) |
commit | 43fb54cd4f27f9c27f114d7b6fb2e04b35441a92 (patch) | |
tree | 4a27f2149ef750c4cdfc68ab7ae314022977aa57 /Lib/test/test_re.py | |
parent | 56379c0d8fc17e717ac1ad73353b5991adae6832 (diff) | |
download | cpython-43fb54cd4f27f9c27f114d7b6fb2e04b35441a92.zip cpython-43fb54cd4f27f9c27f114d7b6fb2e04b35441a92.tar.gz cpython-43fb54cd4f27f9c27f114d7b6fb2e04b35441a92.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 39972d5..438ef26 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 @@ -854,6 +854,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: |