https://github.com/python/cpython/commit/14326da81c1476f942d44acfa7f4d40103f6b5b2 commit: 14326da81c1476f942d44acfa7f4d40103f6b5b2 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: sobolevn <[email protected]> date: 2026-11-13T18:46:55Z summary:
[3.14] gh-142662: Fix interpreter startup crash when `codecs` are not initialized yet (GH-161860) (#161947) 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 52d3ed672ce748..e7f7d737e566e7 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -146,7 +146,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 characters are converted to lower case, spaces and hyphens 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]
