Skip to content

bpo-21983: Fix a crash in ctypes.cast() in case the type argument is a ctypes structured data type. - #3859

Merged
zooba merged 1 commit into
python:masterfrom
orenmn:bpo21983-fix-crash
May 9, 2018
Merged

zooba merged 1 commit into
python:masterfrom
orenmn:bpo21983-fix-crash

Conversation

@orenmn

@orenmn orenmn commented Oct 2, 2017 •

Copy link
Copy Markdown
Contributor

In addition, add tests to test_ctypes to make sure that cast() raises a TypeError in case of a bad type argument (and doesn't crash).

https://bugs.python.org/issue21983

array = array_type()
self.assertRaises(TypeError, cast, array, None)
self.assertRaises(TypeError, cast, array, array_type)
class Struct(Structure):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if cpython does this, but linking to the bug number in the test might be nice.

@eric-wieser eric-wieser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks obviously correct to me, and I can verify the test fails without it.

@miss-islington

Copy link
Copy Markdown
Contributor

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

@miss-islington

Copy link
Copy Markdown
Contributor

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

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @orenmn for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2018
…ed data type (pythonGH-3859)

(cherry picked from commit d518d8b)

Co-authored-by: Oren Milman <orenmn@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-6745 is a backport of this pull request to the 3.7 branch.

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @orenmn and @zooba, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker d518d8bc8d5dac1a1270612f424d33e0e5afc2b5 2.7

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 9, 2018
…ed data type (pythonGH-3859)

(cherry picked from commit d518d8b)

Co-authored-by: Oren Milman <orenmn@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

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

@eric-wieser

Copy link
Copy Markdown
Contributor

@orenmn: Any change you could take a look at #5576, since you've already been looking over ctypes?

miss-islington added a commit that referenced this pull request May 9, 2018
…ed data type (GH-3859)

(cherry picked from commit d518d8b)

Co-authored-by: Oren Milman <orenmn@gmail.com>
@orenmn

orenmn commented May 10, 2018

Copy link
Copy Markdown
Contributor Author

sorry Eric, but i am too busy nowadays...

miss-islington added a commit that referenced this pull request May 26, 2018
…ed data type (GH-3859)

(cherry picked from commit d518d8b)

Co-authored-by: Oren Milman <orenmn@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants