Skip to content

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

Closed

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. added
    docs
    on Apr 15, 2026
  2. 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
  3. added
    type-bug
    3.15
    on Apr 15, 2026
  4. dagangtj commented on Apr 15, 2026

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

    @warsaw
    Member

    @hugovk should this be a 3.15 blocker?

  7. hugovk commented on Sep 12, 2026

    @hugovk
    Member

    Yep, label added.

  8. added a commit that references this issue on Sep 15, 2026
  9. added a commit that references this issue on Sep 15, 2026
  10. Very-cool-guy commented on Nov 20, 2026

    @Very-cool-guy
    Contributor

    uh it seems like help(open) on python 3.15.2 still talks about locale.getencoding?

  11. vstinner commented on Nov 20, 2026

    @vstinner
    Member

    uh it seems like help(open) on python 3.15.2 still talks about locale.getencoding?

    Alright, io.open() docstring wasn't updated yet. It's defined at Modules/_io/_iomodule.c: do you want to propose a PR to update it?

  12. added a commit that references this issue on Nov 20, 2026
  13. added 2 commits that reference this issue on Nov 24, 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.15docsrelease-blockertopic-unicodetype-bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions