Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e039ffe

Browse files
author
Victor Stinner
committed
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.
1 parent 61ec5dc commit e039ffe

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

Misc/NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ Extensions
8383
Library
8484
-------
8585

86+
- Issue #9605: posix.getlogin() decodes the username with file filesystem
87+
encoding and surrogateescape error handler. Patch written by David Watson.
88+
8689
- Issue #9604: posix.initgroups() encodes the username using the fileystem
8790
encoding and surrogateescape error handler. Patch written by David Watson.
8891

@@ -317,7 +320,7 @@ Core and Builtins
317320
Fix a crash if an empty directory called "encodings" exists in sys.path.
318321

319322
- Issue #8589: Decode PYTHONWARNINGS environment variable with the file system
320-
encoding and surrogateespace error handler instead of the locale encoding to
323+
encoding and surrogateescape error handler instead of the locale encoding to
321324
be consistent with os.environ. Add PySys_AddWarnOptionUnicode() function.
322325

323326
- PyObject_Dump() encodes unicode objects to utf8 with backslashreplace (instead

Modules/posixmodule.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,13 +4354,12 @@ posix_getlogin(PyObject *self, PyObject *noargs)
43544354
name = getlogin();
43554355
if (name == NULL) {
43564356
if (errno)
4357-
posix_error();
4357+
posix_error();
43584358
else
4359-
PyErr_SetString(PyExc_OSError,
4360-
"unable to determine login name");
4359+
PyErr_SetString(PyExc_OSError, "unable to determine login name");
43614360
}
43624361
else
4363-
result = PyUnicode_FromString(name);
4362+
result = PyUnicode_DecodeFSDefault(name);
43644363
errno = old_errno;
43654364

43664365
return result;

0 commit comments

Comments
 (0)