Skip to content

Commit 90cb93c

Browse files
[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 2c2d801) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 10c7ce8 commit 90cb93c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎Python/codecs.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ PyObject *_PyCodec_Lookup(const char *encoding)
138138
}
139139

140140
PyInterpreterState *interp = _PyInterpreterState_GET();
141-
assert(interp->codecs.initialized);
141+
if (!interp->codecs.initialized) {
142+
PyErr_SetString(PyExc_SystemError, "Codecs are not initialized");
143+
return NULL;
144+
}
142145

143146
/* Convert the encoding to a normalized Python string: all
144147
ASCII letters are converted to lower case, spaces are

0 commit comments

Comments
 (0)