Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] IO > Text Encoding info outdated #90301

Closed
davidgilbertson mannequin opened this issue Dec 21, 2021 · 6 comments
Closed

[docs] IO > Text Encoding info outdated #90301

davidgilbertson mannequin opened this issue Dec 21, 2021 · 6 comments
Labels
3.11 only security fixes 3.12 bugs and security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@davidgilbertson
Copy link
Mannequin

davidgilbertson mannequin commented Dec 21, 2021

BPO 46143
Nosy @methane, @eryksun, @davidgilbertson

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-12-21.04:42:17.894>
labels = ['type-bug', '3.10', 'docs']
title = '[docs] IO > Text Encoding info outdated'
updated_at = <Date 2021-12-21.09:07:08.224>
user = '/~https://github.com/davidgilbertson'

bugs.python.org fields:

activity = <Date 2021-12-21.09:07:08.224>
actor = 'eryksun'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2021-12-21.04:42:17.894>
creator = 'gilbertson.david'
dependencies = []
files = []
hgrepos = []
issue_num = 46143
keywords = []
message_count = 3.0
messages = ['408983', '408985', '408993']
nosy_count = 4.0
nosy_names = ['methane', 'docs@python', 'eryksun', 'gilbertson.david']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue46143'
versions = ['Python 3.10']

@davidgilbertson
Copy link
Mannequin Author

davidgilbertson mannequin commented Dec 21, 2021

On this page: https://docs.python.org/3/library/io.html#text-encoding it says "there is no concrete plan as of yet, Python may change the default text file encoding to UTF-8 in the future".

On this page https://docs.python.org/3/library/os.html#utf8-mode is says that from 3.7 onwards UTF-8 will be selected by default.

Does that mean that the text in the first section is now outdated, as it was addressed by PEP-540?

I'm a newbie, so apologies if I'm missing something obvious or filing this in the wrong spot.

@davidgilbertson davidgilbertson mannequin added the 3.10 only security fixes label Dec 21, 2021
@davidgilbertson davidgilbertson mannequin added docs Documentation in the Doc dir 3.10 only security fixes type-bug An unexpected behavior, bug, or error labels Dec 21, 2021
@davidgilbertson davidgilbertson mannequin added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error labels Dec 21, 2021
@methane
Copy link
Member

methane commented Dec 21, 2021

UTF-8 mode is not enabled by default. So locale encoding is still the default encoding.

@eryksun
Copy link
Contributor

eryksun commented Dec 21, 2021

The rare circumstance in which UTF-8 mode gets enabled automatically is described in the following paragraph [1]:

If the PYTHONUTF8 environment variable is not set at all, then the
interpreter defaults to using the current locale settings, unless the
current locale is identified as a legacy ASCII-based locale (as
described for PYTHONCOERCECLOCALE), and locale coercion is either 
disabled or fails. In such legacy locales, the interpreter will
default to enabling UTF-8 mode unless explicitly instructed not to do
so.

Note that UTF-8 mode is never enabled automatically in Windows. In contrast to POSIX, the locale encoding in Windows is unrelated to the current LC_CTYPE locale. Instead, the locale encoding gets set to the process code page, which is based on the system locale by default and never changes while a process is running. The system locale may be incompatible with the current LC_CTYPE locale, Windows user locale, and preferred UI language (e.g. for text resources such as error messages), so try to explicitly use UTF-8 for text files whenever possible.

---
[1] https://docs.python.org/3/library/os.html#utf8-mode

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@slateny
Copy link
Contributor

slateny commented Sep 12, 2022

Is there anything to change on the os docs then since the comments on ... use the UTF-8 encoding apply when UTF-8 mode is enabled only? Or should it be clarified, so something like

... other higher level APIs also exhibit different default behaviours [if UTF-8 mode is enabled:]

@methane methane added 3.11 only security fixes 3.12 bugs and security fixes and removed 3.10 only security fixes labels Sep 13, 2022
@methane
Copy link
Member

methane commented Sep 13, 2022

PEP 686 has been accepted.
There is a plan to enable UTF-8 mode by default for now.

It is better to update 3.11 and 3.12 document about PEP 686.

orsenthil pushed a commit that referenced this issue Oct 4, 2022
Doc: Add references to PEP 686.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Oct 4, 2022
Doc: Add references to PEP 686.
(cherry picked from commit 87679a6)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
@orsenthil
Copy link
Member

It is better to update 3.11 and 3.12 document about PEP 686.

SGTM. Thank you.

miss-islington added a commit that referenced this issue Oct 4, 2022
Doc: Add references to PEP 686.
(cherry picked from commit 87679a6)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
mpage pushed a commit to mpage/cpython that referenced this issue Oct 11, 2022
pablogsal pushed a commit that referenced this issue Oct 22, 2022
Doc: Add references to PEP 686.
(cherry picked from commit 87679a6)

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

4 participants