From ae6265f8d06dbec7d08c73ca23dad0f040d09b8e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 15 May 2010 16:27:27 +0000 Subject: 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. --- Modules/pwdmodule.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'Modules/pwdmodule.c') diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index 35a387ad52..b303f95f31 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -132,9 +132,7 @@ pwd_getpwnam(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "U:getpwnam", &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; -- cgit v1.2.1