Skip to content

Commit 03bc32b

Browse files
committed
Add comment
1 parent dcf97f2 commit 03bc32b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Lib/test/test_ctypes/test_struct_fields.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff 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))]

0 commit comments

Comments
 (0)