mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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:
parent
a5785b1524
commit
c39211f51e
5 changed files with 293 additions and 1 deletions
|
@ -1510,10 +1510,14 @@ PyObject *PyUnicode_EncodeFSDefault(PyObject *unicode)
|
|||
return PyUnicode_AsEncodedString(unicode,
|
||||
Py_FileSystemDefaultEncoding,
|
||||
"surrogateescape");
|
||||
} else
|
||||
}
|
||||
else {
|
||||
/* if you change the default encoding, update also
|
||||
PyUnicode_DecodeFSDefaultAndSize() and redecode_filenames() */
|
||||
return PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(unicode),
|
||||
PyUnicode_GET_SIZE(unicode),
|
||||
"surrogateescape");
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PyUnicode_AsEncodedString(PyObject *unicode,
|
||||
|
@ -1680,6 +1684,8 @@ PyUnicode_DecodeFSDefaultAndSize(const char *s, Py_ssize_t size)
|
|||
"surrogateescape");
|
||||
}
|
||||
else {
|
||||
/* if you change the default encoding, update also
|
||||
PyUnicode_EncodeFSDefault() and redecode_filenames() */
|
||||
return PyUnicode_DecodeUTF8(s, size, "surrogateescape");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue