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 | b83575b0a5a798301a85a602a8d888329da0cf88 (patch) | |
tree | 28e0145d0a58bb0c893421c95374c6c8c156259f /Lib | |
parent | 4fc00826024016f1a81ee4453902aa15e1a3ba75 (diff) | |
download | cpython-b83575b0a5a798301a85a602a8d888329da0cf88.zip cpython-b83575b0a5a798301a85a602a8d888329da0cf88.tar.gz cpython-b83575b0a5a798301a85a602a8d888329da0cf88.tar.bz2 |
Issue #10182: The re module doesn't truncate indices to 32 bits anymore.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_re.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index ff2c953..befe0e8 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1,4 +1,5 @@ from test.test_support import verbose, run_unittest, import_module +from test.test_support import precisionbigmemtest, _2G import re from re import Scanner import sys @@ -819,6 +820,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. + @precisionbigmemtest(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: |