gh-99275: Fix SystemError in ctypes during __initsubclass__ (#99283)

This commit is contained in:
Nikita Sobolev 2022-11-13 22:22:45 +03:00 committed by GitHub
parent d329f859b9
commit 343eb0f94b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -424,8 +424,11 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct
}
stgdict = PyType_stgdict(type);
if (!stgdict)
if (!stgdict) {
PyErr_SetString(PyExc_TypeError,
"ctypes state is not initialized");
return -1;
}
/* If this structure/union is already marked final we cannot assign
_fields_ anymore. */