[Python-checkins] bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165)

Serhiy Storchaka webhook-mailer at python.org
Wed Dec 5 14:10:27 EST 2018


https://github.com/python/cpython/commit/34c7f0c04e2b4e715b2c3df1875af8939fbe7d0b
commit: 34c7f0c04e2b4e715b2c3df1875af8939fbe7d0b
branch: master
author: William Grzybowski <wg at FreeBSD.org>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2018-12-05T21:10:18+02:00
summary:

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

files:
M Misc/NEWS.d/next/Library/2018-09-07-10-16-34.bpo-34604.xL7-kG.rst
M Modules/grpmodule.c
M 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
index 562a69124b3d..958b74fd0da6 100644
--- 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
@@ -1,2 +1,3 @@
 Fix possible mojibake in the error message of `pwd.getpwnam` and
-`grp.getgrnam`. Patch by William Grzybowski.
+`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 d426f083111e..ab766b985093 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -247,7 +247,7 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
             PyErr_NoMemory();
         }
         else {
-            PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %S", name);
+            PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %R", name);
         }
         goto out;
     }
diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c
index fd11f848b2ce..e0232b8d589b 100644
--- a/Modules/pwdmodule.c
+++ b/Modules/pwdmodule.c
@@ -257,7 +257,7 @@ pwd_getpwnam_impl(PyObject *module, PyObject *name)
         }
         else {
             PyErr_Format(PyExc_KeyError,
-                         "getpwnam(): name not found: %S", name);
+                         "getpwnam(): name not found: %R", name);
         }
         goto out;
     }



More information about the Python-checkins mailing list