You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IDLE: require encoding argument for textview.view_file #77018
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, bpo-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 bpo-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.
Activity
terryjreedy commentedon Feb 12, 2018
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, bpo-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 bpo-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.
terryjreedy commentedon Feb 12, 2018
New changeset 688722c by Terry Jan Reedy in branch 'master':
bpo-32837: IDLE - require encoding argument for textview.view_file. (GH-5646)
688722c
miss-islington commentedon Feb 12, 2018
New changeset 65c32bb by Miss Islington (bot) in branch '3.7':
bpo-32837: IDLE - require encoding argument for textview.view_file. (GH-5646)
65c32bb
miss-islington commentedon Feb 12, 2018
New changeset 9fad857 by Miss Islington (bot) in branch '3.6':
bpo-32837: IDLE - require encoding argument for textview.view_file. (GH-5646)
9fad857