File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -77,13 +77,20 @@ def __init_subclass__(cls, **kwargs):
7777 class Subclass (BrokenStructure ): ...
7878
7979 def test_max_field_size_gh126937 (self ):
80+ # Classes for big structs should be created successfully.
81+ # (But they most likely can't be instantiated.)
82+ # Here we test the exact limit: the number of *bits* must fit
83+ # in Py_ssize_t.
84+
8085 class X (self .cls ):
8186 _fields_ = [('char' , c_char ),]
8287 max_field_size = sys .maxsize // 8
88+
8389 class Y (self .cls ):
8490 _fields_ = [('largeField' , X * max_field_size )]
8591 class Z (self .cls ):
8692 _fields_ = [('largeField' , c_char * max_field_size )]
93+
8794 with self .assertRaises (ValueError ):
8895 class TooBig (self .cls ):
8996 _fields_ = [('largeField' , X * (max_field_size + 1 ))]
You can’t perform that action at this time.
0 commit comments