Merge pull request #12569 from anntzer/uintptr_t · matplotlib/matplotlib@e02f2c5 · GitHub
Skip to content

Commit e02f2c5

Browse files
authored
Merge pull request #12569 from anntzer/uintptr_t
FIX: Don't confuse uintptr_t and Py_ssize_t.
2 parents 87aa310 + ecec979 commit e02f2c5

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

setupext.py

Lines changed: 3 additions & 1 deletion

src/_tkagg.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// Include our own excerpts from the Tcl / Tk headers
1919
#include "_tkmini.h"
2020

21+
#include "py_converters.h"
22+
2123
#if defined(_MSC_VER)
2224
# define IMG_FORMAT "%d %d %Iu"
2325
#else
@@ -213,9 +215,9 @@ static PyObject *mpl_tk_blit(PyObject *self, PyObject *args)
213215
int x1, x2, y1, y2;
214216
Tk_PhotoHandle photo;
215217
Tk_PhotoImageBlock block;
216-
if (!PyArg_ParseTuple(args, "ns(iin)(iiii)(iiii):blit",
217-
&interp, &photo_name,
218-
&height, &width, &data_ptr,
218+
if (!PyArg_ParseTuple(args, "O&s(iiO&)(iiii)(iiii):blit",
219+
convert_voidptr, &interp, &photo_name,
220+
&height, &width, convert_voidptr, &data_ptr,
219221
&o0, &o1, &o2, &o3,
220222
&x1, &x2, &y1, &y2)) {
221223
goto exit;

src/py_converters.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ int convert_from_attr(PyObject *obj, const char *name, converter func, void *p)
9494
return 1;
9595
}
9696

97+
int convert_voidptr(PyObject *obj, void *p)
98+
{
99+
void **val = (void **)p;
100+
*val = PyLong_AsVoidPtr(obj);
101+
return *val != NULL ? 1 : !PyErr_Occurred();
102+
}
103+
97104
int convert_double(PyObject *obj, void *p)
98105
{
99106
double *val = (double *)p;

src/py_converters.h

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)