diff options
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Modules/main.c b/Modules/main.c index 2d7ed25f5f9..74e48c94732 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -497,16 +497,13 @@ error: static int pymain_run_interactive_hook(int *exitcode) { - PyObject *hook = PyImport_ImportModuleAttrString("sys", - "__interactivehook__"); - if (hook == NULL) { - if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - // no sys.__interactivehook__ attribute - PyErr_Clear(); - return 0; - } + PyObject *hook; + if (PySys_GetOptionalAttrString("__interactivehook__", &hook) < 0) { goto error; } + if (hook == NULL) { + return 0; + } if (PySys_Audit("cpython.run_interactivehook", "O", hook) < 0) { goto error; |