[Python-checkins] r66235 - python/trunk/Lib/test/test_unicode.py

antoine.pitrou python-checkins at python.org
Sat Sep 6 00:04:54 CEST 2008


Author: antoine.pitrou
Date: Sat Sep  6 00:04:54 2008
New Revision: 66235

Log:
#3601: test_unicode.test_raiseMemError fails in UCS4

Reviewed by Benjamin Peterson on IRC.




Modified:
   python/trunk/Lib/test/test_unicode.py

Modified: python/trunk/Lib/test/test_unicode.py
==============================================================================
--- python/trunk/Lib/test/test_unicode.py	(original)
+++ python/trunk/Lib/test/test_unicode.py	Sat Sep  6 00:04:54 2008
@@ -1118,7 +1118,10 @@
         # 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)
 


More information about the Python-checkins mailing list