Skip to content

The asyncio REPL reaches for PYTHONSTARTUP in isolated mode #140648

@bswck

Description

@bswck

Bug report

Bug description:

According to the documentation, all PYTHON* environment variables are ignored when -I is passed as a command-line option to Python.

Let's make the asyncio REPL comply with that by checking sys.flags.isolated before PYTHONSTARTUP.

#140288 rearranges and solidifies startup tests for any REPLs. It will help in testing this. Let's merge that PR first, and I'll submit a patch for this one shortly after.

Reproduction:

$ echo 'print("you should not be seeing this!")' > t.py

$ PYTHONSTARTUP=t.py ./python -Im asyncio
asyncio REPL 3.15.0a1+ (heads/main:06c779474c7, Oct 27 2025, 02:33:08) [GCC 15.2.1 20250808 (Red Hat 15.2.1-1)] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
you should not be seeing this!
>>> import asyncio
>>>

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-asynciotopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions