Issue #9630: Redecode filenames when setting the filesystem encoding
Redecode the filenames of:
- all modules: __file__ and __path__ attributes
- all code objects: co_filename attribute
- sys.path
- sys.meta_path
- sys.executable
- sys.path_importer_cache (keys)
Keep weak references to all code objects until initfsencoding() is called, to
be able to redecode co_filename attribute of all code objects.
diff --git a/Include/code.h b/Include/code.h
index f0f88cd..bdbfaba 100644
--- a/Include/code.h
+++ b/Include/code.h
@@ -99,6 +99,13 @@
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
PyObject *names, PyObject *lineno_obj);
+/* List of weak references to all code objects. The list is used by
+ initfsencoding() to redecode code filenames at startup if the filesystem
+ encoding changes. At initfsencoding() exit, the list is set to NULL and it
+ is no more used. */
+
+extern PyObject *_Py_code_object_list;
+
#ifdef __cplusplus
}
#endif