mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Always initialize Py_FileSystemDefaultEncoding on Unix in Py_Initialize,
and not as a side effect of setlocale. Expose it as sys.getfilesystemencoding. Adjust test case.
This commit is contained in:
parent
620c0837bd
commit
73d538b9c6
6 changed files with 67 additions and 22 deletions
|
@ -236,6 +236,22 @@ PyDoc_STRVAR(setdefaultencoding_doc,
|
|||
Set the current default string encoding used by the Unicode implementation."
|
||||
);
|
||||
|
||||
static PyObject *
|
||||
sys_getfilesystemencoding(PyObject *self)
|
||||
{
|
||||
if (Py_FileSystemDefaultEncoding)
|
||||
return PyString_FromString(Py_FileSystemDefaultEncoding);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(getfilesystemencoding_doc,
|
||||
"getfilesystemencoding() -> string\n\
|
||||
\n\
|
||||
Return the encoding used to convert Unicode filenames in\n\
|
||||
operating system filenames."
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -649,6 +665,10 @@ static PyMethodDef sys_methods[] = {
|
|||
#ifdef DYNAMIC_EXECUTION_PROFILE
|
||||
{"getdxp", _Py_GetDXProfile, METH_VARARGS},
|
||||
#endif
|
||||
#ifdef Py_USING_UNICODE
|
||||
{"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding,
|
||||
METH_NOARGS, getfilesystemencoding_doc},
|
||||
#endif
|
||||
#ifdef Py_TRACE_REFS
|
||||
{"getobjects", _Py_GetObjects, METH_VARARGS},
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue