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-08-30.19:29:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The following code causes PyCData_setstate() (in Modules/_ctypes/_ctypes.c) to
raise a SystemError:

import ctypes
class BadStruct(ctypes.Structure):
    def __dict__(self):

BadStruct().__setstate__({}, b'foo')

this is because PyCData_setstate() assumes that the __dict__ attribute is a dict.

while we are here, I wonder whether we should change the format given to 
PyArg_ParseTuple() to "!Os#", so that the following would raise a TypeError:

import ctypes
class MyStruct(ctypes.Structure):

MyStruct().__setstate__(42, b'foo')

AttributeError: 'int' object has no attribute 'keys'

what do you think?
Date User Action Args
2017-08-30 19:29:41Oren Milmansetrecipients: + Oren Milman
2017-08-30 19:29:41Oren Milmansetmessageid: <>
2017-08-30 19:29:41Oren Milmanlinkissue31311 messages
2017-08-30 19:29:41Oren Milmancreate