https://github.com/python/cpython/commit/90cb93c6954644f2e887d5120933865569f02343 commit: 90cb93c6954644f2e887d5120933865569f02343 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: sobolevn <[email protected]> date: 2026-11-13T18:54:25Z summary:
[3.15] gh-142662: Fix interpreter startup crash when `codecs` are not initialized yet (GH-161860) (#161946) gh-142662: Fix interpreter startup crash when `codecs` are not initialized yet (GH-161860) (cherry picked from commit 2c2d8018a20da33c749f42cc6a4ae55664a88321) Co-authored-by: sobolevn <[email protected]> files: M Python/codecs.c diff --git a/Python/codecs.c b/Python/codecs.c index b78d51858f64e5..5dcad148e8dbaf 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -138,7 +138,10 @@ PyObject *_PyCodec_Lookup(const char *encoding) } PyInterpreterState *interp = _PyInterpreterState_GET(); - assert(interp->codecs.initialized); + if (!interp->codecs.initialized) { + PyErr_SetString(PyExc_SystemError, "Codecs are not initialized"); + return NULL; + } /* Convert the encoding to a normalized Python string: all ASCII letters are converted to lower case, spaces are _______________________________________________ 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]
