bpo-31311: fix a SystemError and a crash in PyCData_setstate(), in case of a bad __dict__#3254
Conversation
| } | ||
| if (!PyDict_Check(mydict)) { | ||
| PyErr_SetString(PyExc_TypeError, | ||
| "__dict__ must be a dictionary"); |
There was a problem hiding this comment.
Add an actual type of __dict__. Add a type of myself.
| from ctypes import Structure | ||
|
|
||
| class BadStruct(Structure): | ||
| def __dict__(self): |
There was a problem hiding this comment.
I think it would be better to use a property. This doesn't work in any case, don't affect instance's dict, but at least looks more realistic.
|
Thanks @orenmn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6. |
…state__(), in case of a bad __dict__. (pythonGH-3254) (cherry picked from commit 57c2561)
|
GH-3743 is a backport of this pull request to the 3.6 branch. |
|
Thanks @orenmn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7. |
|
Sorry, @orenmn and @serhiy-storchaka, I could not cleanly backport this to |
…state__(), in case of a bad __dict__. (pythonGH-3254). (cherry picked from commit 57c2561)
|
GH-3781 is a backport of this pull request to the 2.7 branch. |
_ctypes.c- add checks whether__dict__was retrieved successfully, and whether it is a dictionary.test_parameters.py- add tests to verify that the crash and the SystemError are no more.https://bugs.python.org/issue31311