bpo-36150: Fix possible assertion failures due to _ctypes.c's PyCData_reduce()#12106
Conversation
|
The extra checks are not necessary. O and N handle NULL correctly. |
| if (dict == NULL) { | ||
| return NULL; | ||
| } | ||
| PyObject *bytes = PyBytes_FromStringAndSize(self->b_ptr, self->b_size); |
There was a problem hiding this comment.
It is enough to check for error only dict. PyBytes_FromStringAndSize() can be passed directly to Py_BuildValue().
There was a problem hiding this comment.
You could even use y# instead of PyBytes_FromStringAndSize().
There was a problem hiding this comment.
Thank you, Serhiy. I've updated the PR.
|
Thanks @ZackerySpytz for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.7. |
|
GH-12642 is a backport of this pull request to the 3.7 branch. |
|
Sorry, @ZackerySpytz and @serhiy-storchaka, I could not cleanly backport this to |
…_reduce(). (pythonGH-12106) (cherry picked from commit 5f2c508) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
…_reduce(). (pythonGH-12106) (cherry picked from commit 5f2c508)
|
GH-12643 is a backport of this pull request to the 2.7 branch. |
(This is a "skip news" PR.)
https://bugs.python.org/issue36150