From: Serhiy Storchaka Date: Wed, 5 Dec 2018 21:23:06 +0000 (+0200) Subject: bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165... X-Git-Tag: v3.7.2rc1~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac8b47c8b4edd59aaee857717d434df52ec49e6c;p=thirdparty%2FPython%2Fcpython.git bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165). (GH-10947) (cherry picked from commit 34c7f0c04e2b4e715b2c3df1875af8939fbe7d0b) Co-authored-by: William Grzybowski --- 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 000000000000..958b74fd0da6 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-09-07-10-16-34.bpo-34604.xL7-kG.rst @@ -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. diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c index 43e45ef7aad5..8a724b6b438f 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); + PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %R", name); goto out; } retval = mkgrent(p); diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c index 21c2b546f6dd..810427a229b7 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", arg); + "getpwnam(): name not found: %R", arg); goto out; } retval = mkpwent(p);