Skip to content

gh-148603: Update docs now UTF-8 is default (PEP 686) - #157372

Merged
hugovk merged 4 commits into
python:mainfrom
hugovk:3.15-utf8-docs
Sep 15, 2026
Merged

hugovk merged 4 commits into
python:mainfrom
hugovk:3.15-utf8-docs

Conversation

@hugovk

@hugovk hugovk commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

@read-the-docs-community

read-the-docs-community Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Comment thread Doc/library/csv.rst
Comment thread Doc/using/windows.rst Outdated
Windows still uses legacy encodings for the system encoding (the ANSI Code
Page). Python uses it for the default encoding of text files (e.g.
Page). When the :ref:`Python UTF-8 Mode <utf8-mode>` is disabled, Python
uses it for the default encoding of text files (for example,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads oddly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it, is it better now?

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The changes LGTM, I didn't check if the change is exhaustive (update all references to open() default encoding).

I have a question for @methane about EncodingWarning, but it should not block this PR.

Comment thread Doc/library/io.rst

To find where the default locale encoding is used, you can enable
To find where the default encoding is used, you can enable
the :option:`-X warn_default_encoding <-X>` command line option or set the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@methane: It now looks wrong to emit EncodingWarning if open() is called with no encoding argument, since it defaults to UTF-8 which is fine, no? For me, the purpose of PEP 597 "Add optional EncodingWarning" is to detect when platform dependent locale encoding is used. Am I wrong?

At least, I see one advantage of the current behavior, it helps writing new code which is not platform dependent when running on older Python versions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EncodingWarning is a tool for people who want to identify all the places that will be affected by the transition to UTF-8 Mode and verify that the transition will not cause any problems.

Considering that some people may not start thinking about enabling UTF-8 Mode until Python 3.15, I think removing EncodingWarning immediately in Python 3.15 would be premature. How about removing it in Python 3.17 instead?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since -X warn_default_encoding is an opt-in option to emit EncodingWarning, I'm fine with emitting EncodingWarning on Python 3.15 when the encoding parameter is omitted. As I wrote, it should help writing new code on Python 3.15 which is compatible (behave as expected) on older Python versions.

@hugovk
hugovk merged commit d95f295 into python:main Sep 15, 2026
30 checks passed
@hugovk
hugovk deleted the 3.15-utf8-docs branch September 15, 2026 13:50
@miss-islington-app

Copy link
Copy Markdown

Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Sep 15, 2026

Copy link
Copy Markdown

GH-157556 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 15, 2026
hugovk added a commit that referenced this pull request Sep 15, 2026
…) (#157556)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir release-blocker skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

open() documentation still says default encoding is locale-dependent in 3.15

4 participants