Skip to content

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

Description

@honglei

Documentation

Documentation page

https://docs.python.org/3.15/library/functions.html#open

Bug description

The Python 3.15 open() documentation still says that the default encoding is platform-dependent and comes from locale.getencoding().

But What's New in Python 3.15 says that Python 3.15 now uses UTF-8 as the default encoding for text files by default (PEP 686), independent of the system locale/environment:
https://docs.python.org/3.15/whatsnew/3.15.html#whatsnew315-utf8-default

So these pages appear inconsistent and the open() docs may still have pre-3.15 wording.

Linked PRs

Activity

  1. vstinner commented on Apr 15, 2026

    @vstinner
    Member

    open() now uses the UTF-8 encoding by default, but it still uses the locale encoding if the UTF-8 Mode is disabled:

    $ LANG=fr_FR python3.15 -c 'print(open("/etc/issue").encoding)'
    utf-8
    $ LANG=fr_FR python3.15 -X utf8=0 -c 'print(open("/etc/issue").encoding)'
    ISO-8859-1
  2. added
    type-bugAn unexpected behavior, bug, or error
    3.15bugs and security fixes
    on Apr 15, 2026
  3. dagangtj commented on Apr 15, 2026

    @dagangtj
  4. added a commit that references this issue on Apr 15, 2026
    6fc3be0
  5. warsaw commented on Sep 11, 2026

    @warsaw
    Member

    @hugovk should this be a 3.15 blocker?

  6. hugovk commented on Sep 12, 2026

    @hugovk
    Member

    Yep, label added.

  7. added a commit that references this issue on Sep 15, 2026
  8. added a commit that references this issue on Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15bugs and security fixesdocsDocumentation in the Doc dirrelease-blockertopic-unicodetype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions