From 6d0254bae4d739b487fcaa76705a2d309bce8e75 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 14 Jan 2019 03:17:06 -0800 Subject: [PATCH] bpo-34756: Silence only ImportError and AttributeError in sys.breakpointhook(). (GH-9457) (cherry picked from commit 6fe9c446f8302553952f63fc6d96be4dfa48ceba) Co-authored-by: Serhiy Storchaka --- Python/sysmodule.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Python/sysmodule.c b/Python/sysmodule.c index efe5b29ef33c..75e4f4bf294f 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -171,6 +171,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( -- 2.47.3