]> granicus.if.org Git - python/commitdiff
Merged revisions 66235 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 5 Sep 2008 22:13:06 +0000 (22:13 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 5 Sep 2008 22:13:06 +0000 (22:13 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r66235 | antoine.pitrou | 2008-09-06 00:04:54 +0200 (sam., 06 sept. 2008) | 6 lines

  #3601: test_unicode.test_raiseMemError fails in UCS4

  Reviewed by Benjamin Peterson on IRC.
........

Lib/test/test_unicode.py

index f82a64280eeef24c846c04d1b618b52956c1bbe5..d8c4778c6f0855fe1f02383327c6cba99567f467 100644 (file)
@@ -1160,7 +1160,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: "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: "a" * (sys.maxsize // charwidth * 2)
         self.assertRaises(MemoryError, alloc)
         self.assertRaises(MemoryError, alloc)