bpo-34604: Fix possible mojibake in pwd.getpwnam() and grp.getgrnam() (GH-9098)
Pass the user/group name as Unicode to the formatting function,
instead of always decoding a bytes string from UTF-8.
diff --git a/Modules/grpmodule.c b/Modules/grpmodule.c
index ffdfa1b..74286ab 100644
--- a/Modules/grpmodule.c
+++ b/Modules/grpmodule.c
@@ -245,7 +245,7 @@
PyErr_NoMemory();
}
else {
- PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name_chars);
+ PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %S", name);
}
goto out;
}