From 6fe9c446f8302553952f63fc6d96be4dfa48ceba Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 14 Jan 2019 12:58:37 +0200 Subject: bpo-34756: Silence only ImportError and AttributeError in sys.breakpointhook(). (GH-9457) --- Python/sysmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 10707fd23f..869834b924 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -170,6 +170,12 @@ sys_breakpointhook(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb return retval; error: + if (!PyErr_ExceptionMatches(PyExc_ImportError) + && !PyErr_ExceptionMatches(PyExc_AttributeError)) + { + PyMem_RawFree(envar); + return NULL; + } /* If any of the imports went wrong, then warn and ignore. */ PyErr_Clear(); int status = PyErr_WarnFormat( -- cgit v1.2.1