Skip to content

bpo-31311: fix a SystemError and a crash in PyCData_setstate(), in case of a bad __dict__#3254

Merged
serhiy-storchaka merged 7 commits into
python:masterfrom
orenmn:bpo31311-fix-crash-and-SystemError
Sep 25, 2017
Merged

bpo-31311: fix a SystemError and a crash in PyCData_setstate(), in case of a bad __dict__#3254
serhiy-storchaka merged 7 commits into
python:masterfrom
orenmn:bpo31311-fix-crash-and-SystemError

Conversation

@orenmn

@orenmn orenmn commented Aug 31, 2017

Copy link
Copy Markdown
Contributor
  • in _ctypes.c - add checks whether __dict__ was retrieved successfully, and whether it is a dictionary.
  • in test_parameters.py - add tests to verify that the crash and the SystemError are no more.

https://bugs.python.org/issue31311

Comment thread Modules/_ctypes/_ctypes.c Outdated
}
if (!PyDict_Check(mydict)) {
PyErr_SetString(PyExc_TypeError,
"__dict__ must be a dictionary");

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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.

@serhiy-storchaka serhiy-storchaka added needs backport to 2.7 type-bug An unexpected behavior, bug, or error labels Sep 25, 2017
@serhiy-storchaka
serhiy-storchaka merged commit 57c2561 into python:master Sep 25, 2017
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @orenmn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 25, 2017
…state__(), in case of a bad __dict__. (pythonGH-3254)

(cherry picked from commit 57c2561)
@bedevere-bot

Copy link
Copy Markdown

GH-3743 is a backport of this pull request to the 3.6 branch.

serhiy-storchaka pushed a commit that referenced this pull request Sep 25, 2017
…state__(), in case of a bad __dict__. (GH-3254) (#3743)

(cherry picked from commit 57c2561)
@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @orenmn for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @orenmn and @serhiy-storchaka, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 57c2561c8c5663aef55b00e3f29cba575ff36ccd 2.7

serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Sep 27, 2017
…state__(), in case of a bad __dict__. (pythonGH-3254).

(cherry picked from commit 57c2561)
@bedevere-bot

Copy link
Copy Markdown

GH-3781 is a backport of this pull request to the 2.7 branch.

serhiy-storchaka added a commit that referenced this pull request Sep 27, 2017
…state__(), in case of a bad __dict__. (GH-3254). (#3781)

(cherry picked from commit 57c2561)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants