mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Issue #8715: Create PyUnicode_EncodeFSDefault() function: Encode a Unicode
object to Py_FileSystemDefaultEncoding with the "surrogateescape" error handler, return a bytes object. If Py_FileSystemDefaultEncoding is not set, fall back to UTF-8.
This commit is contained in:
parent
59e62db0a3
commit
ae6265f8d0
10 changed files with 46 additions and 26 deletions
|
@ -118,9 +118,7 @@ static PyObject* spwd_getspnam(PyObject *self, PyObject *args)
|
|||
|
||||
if (!PyArg_ParseTuple(args, "U:getspnam", &arg))
|
||||
return NULL;
|
||||
if ((bytes = PyUnicode_AsEncodedString(arg,
|
||||
Py_FileSystemDefaultEncoding,
|
||||
"surrogateescape")) == NULL)
|
||||
if ((bytes = PyUnicode_EncodeFSDefault(arg)) == NULL)
|
||||
return NULL;
|
||||
if (PyBytes_AsStringAndSize(bytes, &name, NULL) == -1)
|
||||
goto out;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue