bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165). (GH-10947)

(cherry picked from commit 34c7f0c04e)

Co-authored-by: William Grzybowski <wg@FreeBSD.org>
This commit is contained in:
Serhiy Storchaka 2018-12-05 23:23:06 +02:00 committed by GitHub
parent 1de91a0032
commit ac8b47c8b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1,3 @@
Fix possible mojibake in the error message of `pwd.getpwnam` and
`grp.getgrnam` using string representation because of invisible characters
or trailing whitespaces. Patch by William Grzybowski.

View file

@ -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);
PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %R", name);
goto out;
}
retval = mkgrent(p);

View file

@ -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", arg);
"getpwnam(): name not found: %R", arg);
goto out;
}
retval = mkpwent(p);