Skip to content

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

Open
hugovk wants to merge 3 commits into
python:mainfrom
hugovk:3.15-utf8-docs
Open

gh-148603: Update docs now UTF-8 is default (PEP 686)#157372
hugovk wants to merge 3 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

Documentation build overview

📚 cpython-previews | 🛠️ Build #34533562 | 📁 Comparing c3986bc against main (575fe39)

  🔍 Preview build  

15 files changed · + 1 added · ± 13 modified · - 1 deleted

+ Added

± Modified

- Deleted

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge docs Documentation in the Doc dir needs backport to 3.15 pre-release feature fixes, bugs and security fixes release-blocker skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

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

4 participants