[New-bugs-announce] [issue31311] SystemError raised by PyCData_setstate() in case __dict__ is not a dict
Oren Milman
report at bugs.python.org
Wed Aug 30 15:29:41 EDT 2017
New submission from Oren Milman:
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?
----------
components: Extension Modules
messages: 301034
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: SystemError raised by PyCData_setstate() in case __dict__ is not a dict
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31311>
_______________________________________
More information about the New-bugs-announce
mailing list