diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2022-11-13 19:22:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-13 19:22:45 (GMT) |
commit | 343eb0f94b26f2a4c1c15505d417e8157ec19660 (patch) | |
tree | 7d0f28d4f922856a07575c1d4976a91b46ff9820 /Lib | |
parent | d329f859b9cea9e6fa76fdf03927f659cf17786b (diff) | |
download | cpython-343eb0f94b26f2a4c1c15505d417e8157ec19660.zip cpython-343eb0f94b26f2a4c1c15505d417e8157ec19660.tar.gz cpython-343eb0f94b26f2a4c1c15505d417e8157ec19660.tar.bz2 |
gh-99275: Fix `SystemError` in `ctypes` during `__initsubclass__` (#99283)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_ctypes/test_struct_fields.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_ctypes/test_struct_fields.py b/Lib/test/test_ctypes/test_struct_fields.py index ee8415f..fefeaea 100644 --- a/Lib/test/test_ctypes/test_struct_fields.py +++ b/Lib/test/test_ctypes/test_struct_fields.py @@ -54,6 +54,15 @@ class StructFieldsTestCase(unittest.TestCase): x.char = b'a\0b\0' self.assertEqual(bytes(x), b'a\x00###') + def test_gh99275(self): + class BrokenStructure(Structure): + def __init_subclass__(cls, **kwargs): + cls._fields_ = [] # This line will fail, `stgdict` is not ready + + with self.assertRaisesRegex(TypeError, + 'ctypes state is not initialized'): + class Subclass(BrokenStructure): ... + # __set__ and __get__ should raise a TypeError in case their self # argument is not a ctype instance. def test___set__(self): |