@@ -698,11 +698,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
698
698
}
699
699
700
700
static PyObject*
701
- FigureManager_set_icon (PyObject* null, PyObject* args, PyObject* kwds ) {
701
+ FigureManager_set_icon (PyObject* null, PyObject* args) {
702
702
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)) {
706
704
return NULL ;
707
705
}
708
706
const char * icon_path_ptr = PyUnicode_AsUTF8 (icon_path);
@@ -726,8 +724,14 @@ static CGFloat _get_device_scale(CGContextRef cr)
726
724
PyErr_SetString (PyExc_RuntimeError, " Image is not valid" );
727
725
return NULL ;
728
726
}
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
+ }
731
735
}
732
736
Py_RETURN_NONE;
733
737
}
@@ -806,7 +810,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
806
810
METH_NOARGS},
807
811
{" set_icon" ,
808
812
(PyCFunction)FigureManager_set_icon,
809
- METH_STATIC | METH_VARARGS | METH_KEYWORDS ,
813
+ METH_STATIC | METH_VARARGS,
810
814
" Set application icon" },
811
815
{" set_window_title" ,
812
816
(PyCFunction)FigureManager_set_window_title,
0 commit comments