-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Try to make backend_gdk compatible with numpy 1.6 #5080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hmm, trying to restart the 3.4 test but it doesn't want to... Travis says it restarted successfully, but it hasn't restarted... |
return NULL; | ||
} | ||
#else | ||
PyArray_BASE(array) = py_pixbuf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to cast the py_pixbuf
pointer into a PyObject
pointer? py_pixbuf
is type PyGObject*
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because PyArray_SetBaseObject expects a PyObject pointer as its second argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 16 Sep 2015, at 17:18, mdehoon notifications@github.com wrote:
In src/_backend_gdk.c #5080 (comment):
@@ -52,7 +52,15 @@ static PyObject *pixbuf_get_pixels_array(PyObject *self, PyObject *args)
/* the array holds a ref to the pixbuf pixels through this wrapper*/ Py_INCREF(py_pixbuf);
- PyArray_SetBaseObject(array, (PyObject *)py_pixbuf);
+#if NPY_API_VERSION >= 0x00000007- if (PyArray_SetBaseObject(array, (PyObject *)py_pixbuf) == -1) {
Py_DECREF(py_pixbuf);
Py_DECREF(array);
return NULL;
- }
+#else- PyArray_BASE(array) = py_pixbuf;
Yes, because PyArray_SetBaseObject expects a PyObject pointer as its second argument.I guess the question is whether we need to do the cast in the #else branch too. It’s not required in C, but assigning to a pointer to a different type can cause a compiler warning, so it would be slightly cleaner to cast in that branch too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. That was the question I was asking.
BLD: Try to make backend_gdk compatible with numpy 1.6
All the tests pass and cleans up a corner-case failure mode. |
Fixes #5078, at least according to a quick test with
import matplotlib.backends.backend_gdk