-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-31311: fix a SystemError and a crash in PyCData_setstate(), in case of a bad __dict__ #3254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-31311: fix a SystemError and a crash in PyCData_setstate(), in case of a bad __dict__ #3254
Conversation
Modules/_ctypes/_ctypes.c
Outdated
| } | ||
| if (!PyDict_Check(mydict)) { | ||
| PyErr_SetString(PyExc_TypeError, | ||
| "__dict__ must be a dictionary"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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