Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
GH-133711: Enable UTF-8 mode by default (PEP 686)#133712
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
AA-Turner commented May 8, 2025 • edited by github-actions bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by github-actions bot
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Doc/whatsnew/3.15.rst Outdated
| * Python UTF-8 mode is now enabled by default. | ||
| It may be disabled with by setting :envvar:`PYTHONUTF8=0 <PYTHONUTF8>` as | ||
| an environment variable or by using the :option:`-X utf8=0 <-X>` flag. | ||
| See :pep:`686` for further details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we can probably put some more explanation in here, such as that it affects TextIOWrapper and hence open(). The current description doesn't sound as scary as it needs to, in my opinion.
Along the lines of: "Python UTF-8 mode is now enabled by default. This means that (files/console/etc.) will now use UTF-8 regardless of system settings, unless specifically overridden in code (typically with an encoding= argument)."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, it's nothing new. But we shouldn't assume that everyone already knows what UTF-8 mode implies. There are many more people out there who haven't ever thought about it than those who are waiting for it to be the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another effect of the UTF-8 Mode is that Python ignores the locale encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've expanded the What's New entry, please see https://cpython-previews--133712.org.readthedocs.build/en/133712/whatsnew/3.15.html#other-language-changes
Uh oh!
There was an error while loading. Please reload this page.
| ====================== | ||
| * Python now uses UTF-8_ as the default encoding, independent of the system's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might mention the UTF-8 Mode earlier since it has other side effects documented in the UTF-8 Mode section, such as changing sys.stdout error handler and ignoring the locale encoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"default encoding" is UTF-8 since Python 3.0. (e.g. sys.getdefaultencoding())
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts: # Doc/whatsnew/3.15.rst
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as resolved.
This comment was marked as resolved.
vstinner commented May 28, 2025
I wrote #134839 to fix test_regrtest when PYTHONUTF8=1 env var is set. |
vstinner commented May 28, 2025
I wrote #134841 to fix test_readline for the Python UTF-8 Mode. |
This comment was marked as duplicate.
This comment was marked as duplicate.
vstinner commented May 28, 2025
Configure host Python fails with: It seems to be unrelated to this PR. |
AA-Turner commented May 29, 2025
cc @brettcannon, this builder seems to be consistently failing since ~15/05. |
vstinner left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
vstinner commented Jun 16, 2025
Ping @AA-Turner, I made two suggestions. |
vstinner commented Jul 13, 2025
In fact, it would be safe to run this PR on buildbots before merging it. I will wait until GitHub CIs complete first. |
bedevere-bot commented Jul 13, 2025
🤖 New build scheduled with the buildbot fleet by @vstinner for commit 3130318 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133712%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again. |
AA-Turner commented Jul 15, 2025
Thanks @vstinner! A |
c89a66f into python:mainUh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
📚 Documentation preview 📚: https://cpython-previews--133712.org.readthedocs.build/