[Python-checkins] cpython (3.5): Issues #1621, #29145: Test for str.join() overflow

martin.panter python-checkins at python.org
Sat Jan 14 02:25:13 EST 2017


https://hg.python.org/cpython/rev/dd2c7d497878
changeset:   106142:dd2c7d497878
branch:      3.5
user:        Martin Panter <vadmium+py at gmail.com>
date:        Thu Jan 12 11:54:59 2017 +0000
summary:
  Issues #1621, #29145: Test for str.join() overflow

files:
  Lib/test/test_unicode.py |  7 +++++++
  1 files changed, 7 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -464,6 +464,13 @@
         self.checkraises(TypeError, ' ', 'join', [1, 2, 3])
         self.checkraises(TypeError, ' ', 'join', ['1', '2', 3])
 
+    @unittest.skipIf(sys.maxsize > 2**32,
+        'needs too much memory on a 64-bit platform')
+    def test_join_overflow(self):
+        size = int(sys.maxsize**0.5) + 1
+        seq = ('A' * size,) * size
+        self.assertRaises(OverflowError, ''.join, seq)
+
     def test_replace(self):
         string_tests.CommonTest.test_replace(self)
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list