https://github.com/python/cpython/commit/e84e5c6df494d51545a580c09cce33d0ee48c9d6 commit: e84e5c6df494d51545a580c09cce33d0ee48c9d6 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: sobolevn <[email protected]> date: 2026-11-14T21:04:36Z summary:
[3.14] gh-161863: Fix possible `NULL` deref in `_PyErr_Display` (GH-161979) (#162019) gh-161863: Fix possible `NULL` deref in `_PyErr_Display` (GH-161979) (cherry picked from commit 3403de5283fd44bba842638414e07999e0449723) Co-authored-by: sobolevn <[email protected]> files: M Python/pythonrun.c diff --git a/Python/pythonrun.c b/Python/pythonrun.c index a97bc7dbb8e5a1..e4dee3db3ba39e 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -1155,6 +1155,13 @@ _PyErr_Display(PyObject *file, PyObject *unused, PyObject *value, PyObject *tb) } } + // gh-161863: Interpreter can be not fully initialized + // when calling this function. May be not safe to call the import. + PyInterpreterState *interp = _PyInterpreterState_GET(); + if (interp->imports.importlib == NULL) { + goto fallback; + } + // Try first with the stdlib traceback module PyObject *print_exception_fn = PyImport_ImportModuleAttrString( "traceback", _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
