Skip to content

Commit f0a7a81

Browse files
committed
BUG: quirk in sscanf, changing the order fixes it
1 parent 962847d commit f0a7a81

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/matplotlib/backends/tkagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def blit(photoimage, aggimage, bbox=None, colormode=1):
1919
else:
2020
bboxptr = 0
2121
data = np.asarray(aggimage)
22-
dataptr = (data.ctypes.data, data.shape[0], data.shape[1])
22+
dataptr = (data.shape[0], data.shape[1], data.ctypes.data)
2323
try:
2424
tk.call(
2525
"PyAggImagePhoto", photoimage,

src/_tkagg.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#include "_tkmini.h"
2020

2121
#if defined(_MSC_VER)
22-
# define IMG_FORMAT "%Iu %d %d"
22+
# define IMG_FORMAT "%d %d %Iu"
2323
#else
24-
# define IMG_FORMAT "%zu %d %d"
24+
# define IMG_FORMAT "%d %d %zu"
2525
#endif
2626
#define BBOX_FORMAT "%f %f %f %f"
2727

@@ -74,9 +74,9 @@ static int PyAggImagePhoto(ClientData clientdata, Tcl_Interp *interp, int
7474
return TCL_ERROR;
7575
}
7676
/* get buffer from str which is "ptr height width" */
77-
if (sscanf(argv[2], IMG_FORMAT, &pdata, &hdata, &wdata) != 3) {
77+
if (sscanf(argv[2], IMG_FORMAT, &hdata, &wdata, &pdata) != 3) {
7878
TCL_APPEND_RESULT(interp,
79-
"error reading data, expected ptr height width",
79+
"error reading data, expected height width ptr",
8080
(char *)NULL);
8181
return TCL_ERROR;
8282
}

0 commit comments

Comments
 (0)