Issue #9605: posix.getlogin() decodes the username with file filesystem
encoding and surrogateescape error handler. Patch written by David Watson.
Reindent also posix_getlogin(), and fix a typo in the NEWS file.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 7151289..73fab71 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4354,13 +4354,12 @@
name = getlogin();
if (name == NULL) {
if (errno)
- posix_error();
+ posix_error();
else
- PyErr_SetString(PyExc_OSError,
- "unable to determine login name");
+ PyErr_SetString(PyExc_OSError, "unable to determine login name");
}
else
- result = PyUnicode_FromString(name);
+ result = PyUnicode_DecodeFSDefault(name);
errno = old_errno;
return result;