@@ -698,11 +698,9 @@ static CGFloat _get_device_scale(CGContextRef cr)
698698}
699699
700700static 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