]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 5 Dec 2018 22:04:19 +0000 (14:04 -0800)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 5 Dec 2018 22:04:19 +0000 (00:04 +0200)
(cherry picked from commit 34c7f0c04e2b4e715b2c3df1875af8939fbe7d0b)
(cherry picked from commit ac8b47c8b4edd59aaee857717d434df52ec49e6c)

Co-authored-by: William Grzybowski <wg@FreeBSD.org>
Misc/NEWS.d/next/Library/2018-09-07-10-16-34.bpo-34604.xL7-kG.rst [new file with mode: 0644]
Modules/grpmodule.c
Modules/pwdmodule.c

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 (file)
index 0000000..958b74f
--- /dev/null
@@ -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.
index 43e45ef7aad5c1e4bd6786bf608735888e1e81e5..8a724b6b438fc5adf20ec70ef633c7bde514f6c5 100644 (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);
index 21c2b546f6ddaf68ede187f6b756ebaceb153dca..810427a229b7f402236901a5cf13c3c806e6ae3e 100644 (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);