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.
This commit is contained in:
Victor Stinner 2010-09-29 16:35:47 +00:00
parent a5785b1524
commit c39211f51e
5 changed files with 293 additions and 1 deletions

View file

@ -99,6 +99,13 @@ PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
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