Author Oren Milman
Recipients Oren Milman
Date 2017-08-30.19:29:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1504121381.44.0.97838192699.issue31311@psf.upfronthosting.co.za>
In-reply-to
Content
The following code causes PyCData_setstate() (in Modules/_ctypes/_ctypes.c) to
raise a SystemError:

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

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):
    pass

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

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


what do you think?
History
Date User Action Args
2017-08-30 19:29:41Oren Milmansetrecipients: + Oren Milman
2017-08-30 19:29:41Oren Milmansetmessageid: <1504121381.44.0.97838192699.issue31311@psf.upfronthosting.co.za>
2017-08-30 19:29:41Oren Milmanlinkissue31311 messages
2017-08-30 19:29:41Oren Milmancreate