classification
Title: IDLE: require encoding argument for textview.view_file
Type: behavior Stage: resolved
Components: IDLE Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: miss-islington, terry.reedy
Priority: normal Keywords: patch

Created on 2018-02-12 22:07 by terry.reedy, last changed 2018-02-13 06:28 by terry.reedy. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 5646 merged terry.reedy, 2018-02-12 22:18
PR 5647 merged miss-islington, 2018-02-12 22:43
PR 5648 merged miss-islington, 2018-02-12 22:44
Messages (4)
msg312085 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-02-12 22:07
Built-in open has an encoding parameter whose default value depends on the system: 'ascii' for some POSIX locales; 'latin1' or similar for most Windows sold in the USA or western Europe; and ???.  In idlelib.textview, the signature for view_file currently includes 'encoding=None'.  There have been 2 issues, #32826 and another, about tests using the default failing because of 'Löwis' on line 27 of CREDITS.txt.  It therefore seems an error for a global cross-platform application to use the default encoding.

To prevent this, we should remove '=None' from the encoding part of the view_file definition and make view_file calls explicitly pass an encoding.  For IDLE itself, this will be 'ascii' or 'utf-8'.

This expands upon a note by Cheryl Sabella in #32826 about one of the three calls that fail with the change until fixed.

I will not default to 'utf-8' because 'ascii' catches erroneous non-ascii characters in ascii-only files.  For instance, a draft of README.txt was prepared with an editor that replaced ascii " and " with left and right quotes.  I will not restricting the encoding otherwise because there might be external uses of the file that use other encodings.

PR to follow as soon as I get bpo number.
msg312087 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-02-12 22:42
New changeset 688722cedd6437910ff185ecf94fb3b749ad37f2 by Terry Jan Reedy in branch 'master':
bpo-32837: IDLE - require encoding argument for textview.view_file. (GH-5646)
https://github.com/python/cpython/commit/688722cedd6437910ff185ecf94fb3b749ad37f2
msg312089 - (view) Author: miss-islington (miss-islington) Date: 2018-02-12 23:15
New changeset 65c32bbe85862ab5eb52a0d4340e844e13d0f7ee by Miss Islington (bot) in branch '3.7':
bpo-32837: IDLE - require encoding argument for textview.view_file. (GH-5646)
https://github.com/python/cpython/commit/65c32bbe85862ab5eb52a0d4340e844e13d0f7ee
msg312090 - (view) Author: miss-islington (miss-islington) Date: 2018-02-12 23:40
New changeset 9fad857444d90b9c6c36c31f5f07e57f390a70f2 by Miss Islington (bot) in branch '3.6':
bpo-32837: IDLE - require encoding argument for textview.view_file. (GH-5646)
https://github.com/python/cpython/commit/9fad857444d90b9c6c36c31f5f07e57f390a70f2
History
Date User Action Args
2018-02-13 06:28:23terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-02-12 23:40:14miss-islingtonsetmessages: + msg312090
2018-02-12 23:15:05miss-islingtonsetnosy: + miss-islington
messages: + msg312089
2018-02-12 22:44:50miss-islingtonsetpull_requests: + pull_request5449
2018-02-12 22:43:55miss-islingtonsetpull_requests: + pull_request5448
2018-02-12 22:42:44terry.reedysetmessages: + msg312087
2018-02-12 22:18:05terry.reedysetkeywords: + patch
stage: commit review -> patch review
pull_requests: + pull_request5447
2018-02-12 22:07:39terry.reedycreate