8000 Apply changes from review · matplotlib/matplotlib@8ba946b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ba946b

Browse files
committed
Apply changes from review
1 parent c5a1fcf commit 8ba946b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/_macosx.m

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
698698
}
699699

700700
static PyObject*
701-
FigureManager_set_icon(PyObject* null, PyObject* args, PyObject* kwds) {
701+
FigureManager_set_icon(PyObject* null, PyObject* args) {
702702
PyObject* icon_path;
703-
static char* kwlist[3] = { "icon_path", NULL };
704-
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O&", kwlist,
705-
&PyUnicode_FSDecoder, &icon_path)) {
703+
if (!PyArg_ParseTuple(args, "O&", &PyUnicode_FSDecoder, &icon_path)) {
706704
return NULL;
707705
}
708706
const char* icon_path_ptr = PyUnicode_AsUTF8(icon_path);
@@ -726,8 +724,14 @@ static CGFloat _get_device_scale(CGContextRef cr)
726724
PyErr_SetString(PyExc_RuntimeError, "Image is not valid");
727725
return NULL;
728726
}
729-
NSApplication* app = [NSApplication sharedApplication];
730-
app.applicationIconImage = image;
727+
@try {
728+
NSApplication* app = [NSApplication sharedApplication];
729+
app.applicationIconImage = image;
730+
}
731+
@catch (NSException* exception) {
732+
PyErr_SetString(PyExc_RuntimeError, exception.reason.UTF8String);
733+
return NULL;
734+
}
731735
}
732736
Py_RETURN_NONE;
733737
}
@@ -806,7 +810,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
806810
METH_NOARGS},
807811
{"set_icon",
808812
(PyCFunction)FigureManager_set_icon,
809-
METH_STATIC | METH_VARARGS | METH_KEYWORDS,
813+
METH_STATIC | METH_VARARGS,
810814
"Set application icon"},
811815
{"set_window_title",
812816
(PyCFunction)FigureManager_set_window_title,

0 commit comments

Comments
 (0)
0