Skip to content

Top-level code environment docs are outdated for Python 3.13+ #128720

Closed
@wimglenn

Description

@wimglenn

Bug report

Bug description:

Ref: https://docs.python.org/3/library/__main__.html

There is a script and entry-point example which has a conditional upon __main__.__file__ and also a remark like:

Note that in this case the __main__ scope doesn’t contain a __file__ attribute as it’s interactive.

This was all working as demonstrated up to and including Python 3.12, but starting in Python 3.13 it's incorrect. The attribute now exists, and is pointing at _pyrepl/__main__.py.

The conditional demonstrated in namely.py:print_user_name now always goes into the if branch, and no longer the else branch, resulting in confusing output.

Ping also @jdevries3133 who wrote the original prose in #26883

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions