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 ef1b1a4

Browse filesBrowse files
committed
Fix #5944: Fix PNG writing from notebook backend
1 parent 1c5a45a commit ef1b1a4
Copy full SHA for ef1b1a4

File tree

Expand file treeCollapse file tree

1 file changed

+12
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-12
lines changed

‎src/_png.cpp

Copy file name to clipboardExpand all lines: src/_png.cpp
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,21 @@ static PyObject *Py_write_png(PyObject *self, PyObject *args, PyObject *kwds)
214214
#endif
215215
fp = mpl_PyFile_Dup(py_file, (char *)"wb", &offset);
216216
}
217-
}
218217

219-
if (fp) {
220-
close_dup_file = true;
221-
} else {
222-
PyErr_Clear();
223-
PyObject *write_method = PyObject_GetAttrString(py_file, "write");
224-
if (!(write_method && PyCallable_Check(write_method))) {
218+
if (fp) {
219+
close_dup_file = true;
220+
} else {
221+
PyErr_Clear();
222+
PyObject *write_method = PyObject_GetAttrString(py_file, "write");
223+
if (!(write_method && PyCallable_Check(write_method))) {
224+
Py_XDECREF(write_method);
225+
PyErr_SetString(PyExc_TypeError,
226+
"Object does not appear to be a 8-bit string path or "
227+
"a Python file-like object");
228+
goto exit;
229+
}
225230
Py_XDECREF(write_method);
226-
PyErr_SetString(PyExc_TypeError,
227-
"Object does not appear to be a 8-bit string path or "
228-
"a Python file-like object");
229-
goto exit;
230231
}
231-
Py_XDECREF(write_method);
232232
}
233233

234234
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.