8000 Backport PR #12569: Don't confuse uintptr_t and Py_ssize_t. · matplotlib/matplotlib@0396ad6 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0396ad6

Browse files
tacaswellMeeseeksDev[bot]
authored and
MeeseeksDev[bot]
committed
Backport PR #12569: Don't confuse uintptr_t and Py_ssize_t.
1 parent 77fa285 commit 0396ad6

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

setupext.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,11 +1363,13 @@ def check(self):
13631363

13641364
def get_extension(self):
13651365
sources = [
1366-
'src/_tkagg.cpp'
1366+
'src/_tkagg.cpp',
1367+
'src/py_converters.cpp',
13671368
]
13681369

13691370
ext = make_extension('matplotlib.backends._tkagg', sources)
13701371
self.add_flags(ext)
1372+
Numpy().add_flags(ext)
13711373
LibAgg().add_flags(ext, add_sources=False)
13721374
return ext
13731375

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
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ typedef int (*converter)(PyObject *, void *);
2323
int convert_from_attr(PyObject *obj, const char *name, converter func, void *p);
2424
int convert_from_method(PyObject *obj, const char *name, converter func, void *p);
2525

26+
int convert_voidptr(PyObject *obj, void *p);
2627
int convert_double(PyObject *obj, void *p);
2728
int convert_bool(PyObject *obj, void *p);
2829
int convert_cap(PyObject *capobj, void *capp);

0 commit comments

Comments
 (0)
0