diff --git a/Modules/zipimport.c b/Modules/zipimport.c index ba449c0..9d4b633 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -803,6 +803,15 @@ read_directory(PyObject *archive_obj) if (flags & 0x0800) charset = "utf-8"; + else if (!PyThreadState_GET()->interp->codecs_initialized) { + /* During bootstrap, we may need to load the encodings + package from a ZIP file. But the cp437 encoding is implemented + in Python in the encodings package. + + Break out of this dependency by assuming that the path to + the encodings module is ASCII-only. */ + charset = "ascii"; + } else charset = "cp437"; nameobj = PyUnicode_Decode(name, name_size, charset, NULL);