diff options
author | William Grzybowski <wg@FreeBSD.org> | 2018-09-09 08:27:31 -0300 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-09-09 13:27:31 +0200 |
commit | 7a633ed79cfba2cfc0f80410ddcaeecadc2030e9 (patch) | |
tree | e2eaa34c94f6b2831613a58ac85678f23aeb9bba | |
parent | 77b92b15a5e5c84b91d3fd9d02f63db432fa8903 (diff) | |
download | cpython-git-7a633ed79cfba2cfc0f80410ddcaeecadc2030e9.tar.gz |
[3.7] bpo-34604: Fix possible mojibake in pwd.getpwnam() and grp.getgrnam() (GH-9098) (GH-9104)
Pass the user/group name as Unicode to the formatting function,
instead of always decoding a bytes string from UTF-8..
(cherry picked from commit 28658485a54ad5f9df52ecc12d9046269f1654ec)
Co-authored-by: William Grzybowski <wg@FreeBSD.org>
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-09-07-10-16-34.bpo-34604.xL7-kG.rst | 2 | ||||
-rw-r--r-- | Modules/grpmodule.c | 2 | ||||
-rw-r--r-- | Modules/pwdmodule.c | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Library/2018-09-07-10-16-34.bpo-34604.xL7-kG.rst b/Misc/NEWS.d/next/Library/2018-09-07-10-16-34.bpo-34604.xL7-kG.rst new file mode 100644 index 0000000000..562a69124b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-09-07-10-16-34.bpo-34604.xL7-kG.rst @@ -0,0 +1,2 @@ +Fix possible mojibake in the error message of `pwd.getpwnam` and +`grp.getgrnam`. Patch by William Grzybowski. diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index f577fd3ab4..43e45ef7aa 100644 --- a/Modules/grpmodule.c +++ b/Modules/grpmodule.c @@ -156,7 +156,7 @@ grp_getgrnam_impl(PyObject *module, PyObject *name) goto out; if ((p = getgrnam(name_chars)) == NULL) { - PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name_chars); + PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %S", name); goto out; } retval = mkgrent(p); diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index bbef2de9c5..21c2b546f6 100644 --- a/Modules/pwdmodule.c +++ b/Modules/pwdmodule.c @@ -163,7 +163,7 @@ pwd_getpwnam_impl(PyObject *module, PyObject *arg) goto out; if ((p = getpwnam(name)) == NULL) { PyErr_Format(PyExc_KeyError, - "getpwnam(): name not found: %s", name); + "getpwnam(): name not found: %S", arg); goto out; } retval = mkpwent(p); |