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 ecce9ae

Browse filesBrowse files
authored
Merge pull request #23089 from anntzer/tkie
Normalize tk load failures to ImportErrors.
2 parents dd434d6 + 9cce264 commit ecce9ae
Copy full SHA for ecce9ae

File tree

Expand file treeCollapse file tree

1 file changed

+10
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-4
lines changed

‎src/_tkagg.cpp

Copy file name to clipboardExpand all lines: src/_tkagg.cpp
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,22 @@ static PyModuleDef _tkagg_module = {
341341
PyMODINIT_FUNC PyInit__tkagg(void)
342342
{
343343
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);
345351
return NULL;
346352
} else if (!TCL_SETVAR) {
347-
PyErr_SetString(PyExc_RuntimeError, "Failed to load Tcl_SetVar");
353+
PyErr_SetString(PyExc_ImportError, "Failed to load Tcl_SetVar");
348354
return NULL;
349355
} 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");
351357
return NULL;
352358
} 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");
354360
return NULL;
355361
}
356362
return PyModule_Create(&_tkagg_module);

0 commit comments

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