This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Possible mojibake in pwd.getpwnam and grp.getgrnam
Type: Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, vstinner, wg
Priority: normal Keywords: patch

Created on 2018-09-07 13:14 by wg, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 9098 merged wg, 2018-09-07 13:34
PR 9104 merged wg, 2018-09-07 17:45
PR 9105 merged wg, 2018-09-07 17:46
PR 9165 merged wg, 2018-09-11 14:50
PR 10947 merged serhiy.storchaka, 2018-12-05 20:32
PR 10954 merged miss-islington, 2018-12-05 21:23
Messages (13)
msg324738 - (view) Author: William Grzybowski (wg) * Date: 2018-09-07 13:14
Issue was spotted by @vstinner while reviewing https://github.com/python/cpython/pull/7081

pwd.getpwnam and grp.getgrnam are susceptible to mojibake as they are using encoded bytes instead of unicode in the error message.
msg324772 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-07 17:10
New changeset 28658485a54ad5f9df52ecc12d9046269f1654ec by Victor Stinner (William Grzybowski) in branch 'master':
bpo-34604: Fix possible mojibake in pwd.getpwnam() and grp.getgrnam() (GH-9098)
https://github.com/python/cpython/commit/28658485a54ad5f9df52ecc12d9046269f1654ec
msg324805 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-07 22:07
Wouldn't be better to use %R? The name can contain invisible characters or trailing whitespaces, in which case the traceback can look confusing. Since names are likely created with PyUnicode_DecodeFSDefault(), they can contain undecodable bytes represented as surrogates U+D8XX if the current filesystem encoding doesn't match the filesystem encoding used for creating entries.
msg324806 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-07 22:09
%R sounds like a good idea, but I suggest to only use %R in the master branch.
msg324831 - (view) Author: William Grzybowski (wg) * Date: 2018-09-08 11:37
What is the policy to amend a new commit to master for %R? Create a new PR? Wont that cause problem with NEWS entry?
msg324879 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-09 11:26
New changeset 1bcd891c200b8122493ddad5a203331e1a3bfcb5 by Victor Stinner (William Grzybowski) in branch '3.6':
[3.6] bpo-34604: Fix possible mojibake in pwd.getpwnam() and grp.getgrnam() (GH-9098) (GH-9105)
https://github.com/python/cpython/commit/1bcd891c200b8122493ddad5a203331e1a3bfcb5
msg324880 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-09 11:27
New changeset 7a633ed79cfba2cfc0f80410ddcaeecadc2030e9 by Victor Stinner (William Grzybowski) in branch '3.7':
[3.7] bpo-34604: Fix possible mojibake in pwd.getpwnam() and grp.getgrnam() (GH-9098) (GH-9104)
https://github.com/python/cpython/commit/7a633ed79cfba2cfc0f80410ddcaeecadc2030e9
msg324882 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-09 11:34
The bug has been fixed. For %R, does someone want to propose a change for master? William?
msg324924 - (view) Author: William Grzybowski (wg) * Date: 2018-09-10 13:37
I can do it if you feel the need.
Can this same issue be used? Will the new PR require another NEWS entry?
msg324949 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-09-10 18:36
> I can do it if you feel the need. Can this same issue be used? Will the new PR require another NEWS entry?

Sure, reuse the same bpo number. You can modify the NEWS entry that you added ;-)
msg331141 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-05 19:10
New changeset 34c7f0c04e2b4e715b2c3df1875af8939fbe7d0b by Serhiy Storchaka (William Grzybowski) in branch 'master':
bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165)
https://github.com/python/cpython/commit/34c7f0c04e2b4e715b2c3df1875af8939fbe7d0b
msg331170 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-05 21:23
New changeset ac8b47c8b4edd59aaee857717d434df52ec49e6c by Serhiy Storchaka in branch '3.7':
bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165). (GH-10947)
https://github.com/python/cpython/commit/ac8b47c8b4edd59aaee857717d434df52ec49e6c
msg331181 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-05 22:04
New changeset 3a9b3346b03796d8573c063ab4c2407043609459 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6':
bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165). (GH-10947) (GH-10954)
https://github.com/python/cpython/commit/3a9b3346b03796d8573c063ab4c2407043609459
History
Date User Action Args
2022-04-11 14:59:05adminsetgithub: 78785
2018-12-05 22:09:34serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: - Python 2.7
2018-12-05 22:04:23serhiy.storchakasetmessages: + msg331181
2018-12-05 21:23:17miss-islingtonsetpull_requests: + pull_request10203
2018-12-05 21:23:08serhiy.storchakasetmessages: + msg331170
2018-12-05 20:32:55serhiy.storchakasetpull_requests: + pull_request10197
2018-12-05 19:10:25serhiy.storchakasetmessages: + msg331141
2018-09-11 14:50:32wgsetpull_requests: + pull_request8608
2018-09-10 18:36:59vstinnersetmessages: + msg324949
2018-09-10 13:37:26wgsetmessages: + msg324924
2018-09-09 11:34:06vstinnersetmessages: + msg324882
2018-09-09 11:27:35vstinnersetmessages: + msg324880
2018-09-09 11:26:58vstinnersetmessages: + msg324879
2018-09-08 11:37:13wgsetmessages: + msg324831
2018-09-07 22:09:08vstinnersetmessages: + msg324806
2018-09-07 22:07:18serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg324805
2018-09-07 17:46:08wgsetpull_requests: + pull_request8559
2018-09-07 17:45:26wgsetpull_requests: + pull_request8558
2018-09-07 17:10:43vstinnersetmessages: + msg324772
2018-09-07 13:34:48wgsetkeywords: + patch
stage: patch review
pull_requests: + pull_request8552
2018-09-07 13:24:23vstinnersetnosy: + vstinner

versions: + Python 2.7, - Python 3.4, Python 3.5
2018-09-07 13:14:54wgcreate