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):
77
77
class Subclass (BrokenStructure ): ...
78
78
79
79
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
+
80
85
class X (self .cls ):
81
86
_fields_ = [('char' , c_char ),]
82
87
max_field_size = sys .maxsize // 8
88
+
83
89
class Y (self .cls ):
84
90
_fields_ = [('largeField' , X * max_field_size )]
85
91
class Z (self .cls ):
86
92
_fields_ = [('largeField' , c_char * max_field_size )]
93
+
87
94
with self .assertRaises (ValueError ):
88
95
class TooBig (self .cls ):
89
96
_fields_ = [('largeField' , X * (max_field_size + 1 ))]
You can’t perform that action at this time.
0 commit comments