bpo-34756: Silence only ImportError and AttributeError in sys.breakpointhook(). (GH-9457)
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 10707fd..869834b 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -170,6 +170,12 @@
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(