File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Original file line number Diff line number Diff line change @@ -341,16 +341,22 @@ static PyModuleDef _tkagg_module = {
341
341
PyMODINIT_FUNC PyInit__tkagg (void )
342
342
{
343
343
load_tkinter_funcs ();
344
- if (PyErr_Occurred ()) {
344
+ PyObject *type, *value, *traceback;
345
+ PyErr_Fetch (&type, &value, &traceback);
346
+ // Always raise ImportError (normalizing a previously set exception if
347
+ // needed) to interact properly with backend auto-fallback.
348
+ if (value) {
349
+ PyErr_NormalizeException (&type, &value, &traceback);
350
+ PyErr_SetObject (PyExc_ImportError, value);
345
351
return NULL ;
346
352
} else if (!TCL_SETVAR) {
347
- PyErr_SetString (PyExc_RuntimeError , " Failed to load Tcl_SetVar" );
353
+ PyErr_SetString (PyExc_ImportError , " Failed to load Tcl_SetVar" );
348
354
return NULL ;
349
355
} else if (!TK_FIND_PHOTO) {
350
- PyErr_SetString (PyExc_RuntimeError , " Failed to load Tk_FindPhoto" );
356
+ PyErr_SetString (PyExc_ImportError , " Failed to load Tk_FindPhoto" );
351
357
return NULL ;
352
358
} else if (!TK_PHOTO_PUT_BLOCK) {
353
- PyErr_SetString (PyExc_RuntimeError , " Failed to load Tk_PhotoPutBlock" );
359
+ PyErr_SetString (PyExc_ImportError , " Failed to load Tk_PhotoPutBlock" );
354
360
return NULL ;
355
361
}
356
362
return PyModule_Create (&_tkagg_module);
You can’t perform that action at this time.
0 commit comments