diff -r 38535d6a2015 Lib/test/test_unicode.py --- a/Lib/test/test_unicode.py Sat Aug 23 17:15:31 2008 +0200 +++ b/Lib/test/test_unicode.py Sat Aug 23 21:44:57 2008 +0200 @@ -1118,7 +1118,10 @@ class UnicodeTest( # when a string allocation fails with a MemoryError. # This used to crash the interpreter, # or leak references when the number was smaller. - alloc = lambda: u"a" * (sys.maxsize - 100) + charwidth = 4 if sys.maxunicode >= 0x10000 else 2 + # Note: sys.maxsize is half of the actual max allocation because of + # the signedness of Py_ssize_t. + alloc = lambda: u"a" * (sys.maxsize // charwidth * 2) self.assertRaises(MemoryError, alloc) self.assertRaises(MemoryError, alloc)