This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Oren Milman
Recipients Oren Milman
Date 2017-09-16.09:57:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The following code causes an assertion failure:
import ctypes
class BadStruct(ctypes.Structure):
    _fields_ = []
    _anonymous_ = ['foo']
    foo = None

this is because MakeAnonFields() (in Modules/_ctypes/stgdict.c) goes over the
names specified in _anonymous_, and looks each name up in the class by calling
in case an attribute of such a name is found (i.e. PyObject_GetAttr() succeeded),
MakeAnonFields() assumes that the attribute was created by MakeFields(), so it
asserts the type of the attribute is PyCField_Type.

however, PyObject_GetAttr() would succeed also in case it is a normal attribute
specified by the user, but isn't specified in _fields_, as in the code above.
in such a case, the type of the attribute is not PyCField_Type, and so the
assertion fails.
Date User Action Args
2017-09-16 09:57:38Oren Milmansetrecipients: + Oren Milman
2017-09-16 09:57:38Oren Milmansetmessageid: <>
2017-09-16 09:57:38Oren Milmanlinkissue31490 messages
2017-09-16 09:57:38Oren Milmancreate