Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a9b334

Browse files
miss-islingtonwilliam-gr
authored andcommitted
bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165). (GH-10947) (GH-10954)
(cherry picked from commit 34c7f0c) (cherry picked from commit ac8b47c) Co-authored-by: William Grzybowski <[email protected]>
1 parent fdf5050 commit 3a9b334

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix possible mojibake in the error message of `pwd.getpwnam` and
2+
`grp.getgrnam` using string representation because of invisible characters
3+
or trailing whitespaces. Patch by William Grzybowski.

Modules/grpmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ grp_getgrnam_impl(PyObject *module, PyObject *name)
156156
goto out;
157157

158158
if ((p = getgrnam(name_chars)) == NULL) {
159-
PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %S", name);
159+
PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %R", name);
160160
goto out;
161161
}
162162
retval = mkgrent(p);

Modules/pwdmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pwd_getpwnam_impl(PyObject *module, PyObject *arg)
163163
goto out;
164164
if ((p = getpwnam(name)) == NULL) {
165165
PyErr_Format(PyExc_KeyError,
166-
"getpwnam(): name not found: %S", arg);
166+
"getpwnam(): name not found: %R", arg);
167167
goto out;
168168
}
169169
retval = mkpwent(p);

0 commit comments

Comments
 (0)