classification
Title: Possible mojibake in pwd.getpwnam and grp.getgrnam
Type: Stage: patch review
Components: Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: open Resolution:
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 2018-09-11 14:50 by wg.

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 open wg, 2018-09-11 14:50
Messages (10)
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 ;-)
History
Date User Action Args
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