File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -2370,14 +2370,9 @@ def test_expandtabs_optimization(self):
23702370 self .assertIs (s .expandtabs (), s )
23712371
23722372 def test_raiseMemError (self ):
2373- if struct .calcsize ('P' ) == 8 :
2374- # 64 bits pointers
2375- ascii_struct_size = 48
2376- compact_struct_size = 72
2377- else :
2378- # 32 bits pointers
2379- ascii_struct_size = 24
2380- compact_struct_size = 36
2373+ null_byte = 1
2374+ ascii_struct_size = sys .getsizeof ("a" ) - len ("a" ) - null_byte
2375+ compact_struct_size = sys .getsizeof ("\xff " ) - len ("\xff " ) - null_byte
23812376
23822377 for char in ('a' , '\xe9 ' , '\u20ac ' , '\U0010ffff ' ):
23832378 code = ord (char )
@@ -2395,8 +2390,9 @@ def test_raiseMemError(self):
23952390 # be allocatable, given enough memory.
23962391 maxlen = ((sys .maxsize - struct_size ) // char_size )
23972392 alloc = lambda : char * maxlen
2398- self .assertRaises (MemoryError , alloc )
2399- self .assertRaises (MemoryError , alloc )
2393+ with self .subTest (char = char ):
2394+ self .assertRaises (MemoryError , alloc )
2395+ self .assertRaises (MemoryError , alloc )
24002396
24012397 def test_format_subclass (self ):
24022398 class S (str ):
You can’t perform that action at this time.
0 commit comments