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 <rep...@bugs.python.org> <http://bugs.python.org/issue31311> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com