diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2011-09-28 08:03:28 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2011-09-28 08:03:28 (GMT) |
commit | 287eca658d472b737746a0c25d3bf5d041cfd89b (patch) | |
tree | a033c02bf54db72b25ba5d0e9a5e304667f8d3a5 /Lib/test | |
parent | f02aa65acb7b1b66ac7898680e5a6817c380f7eb (diff) | |
download | cpython-287eca658d472b737746a0c25d3bf5d041cfd89b.zip cpython-287eca658d472b737746a0c25d3bf5d041cfd89b.tar.gz cpython-287eca658d472b737746a0c25d3bf5d041cfd89b.tar.bz2 |
Fix struct sizes. Drop -1, since the resulting string was actually the largest one
that could be allocated.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_unicode.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index f256ba6..b903fbe9 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1585,12 +1585,12 @@ class UnicodeTest(string_tests.CommonTest, def test_raiseMemError(self): if struct.calcsize('P') == 8: # 64 bits pointers - ascii_struct_size = 64 - compact_struct_size = 88 + ascii_struct_size = 48 + compact_struct_size = 72 else: # 32 bits pointers - ascii_struct_size = 32 - compact_struct_size = 44 + ascii_struct_size = 24 + compact_struct_size = 36 for char in ('a', '\xe9', '\u20ac', '\U0010ffff'): code = ord(char) @@ -1604,8 +1604,9 @@ class UnicodeTest(string_tests.CommonTest, char_size = 4 # sizeof(Py_UCS4) struct_size = compact_struct_size # Note: sys.maxsize is half of the actual max allocation because of - # the signedness of Py_ssize_t. -1 because of the null character. - maxlen = ((sys.maxsize - struct_size) // char_size) - 1 + # the signedness of Py_ssize_t. Strings of maxlen-1 should in principle + # be allocatable, given enough memory. + maxlen = ((sys.maxsize - struct_size) // char_size) alloc = lambda: char * maxlen self.assertRaises(MemoryError, alloc) self.assertRaises(MemoryError, alloc) |