]> granicus.if.org Git - python/commitdiff
#3601: test_unicode.test_raiseMemError fails in UCS4
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 5 Sep 2008 22:04:54 +0000 (22:04 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 5 Sep 2008 22:04:54 +0000 (22:04 +0000)
Reviewed by Benjamin Peterson on IRC.

Lib/test/test_unicode.py

index 5d887ed92f04d05f30e8af00253711a18328844c..70e4787b0abd776c735c8a4d7e547081b82e18d1 100644 (file)
@@ -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)