-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed as not planned
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Script to reproduce:
#!/usr/bin/env bash
echo "Python version: $(python3 --version)"
cd $(mktemp -d)
echo "PWD is $PWD"
echo 'x=5' > startup.py
PYTHONSTARTUP="startup.py" python3
PYTHONSTARTUP="startup.py" python3 -m asyncio
cd - > /dev/null
echo "PWD is $PWD"Current behaviour
$ ./repro.sh
Python version: Python 3.12.3
PWD is /tmp/tmp.lVtvc63MZq
Python 3.12.3 (main, Nov 6 2025, 13:44:16) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x
5
>>> ^D
asyncio REPL 3.12.3 (main, Nov 6 2025, 13:44:16) [GCC 13.3.0] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> x
Traceback (most recent call last):
File "/usr/lib/python3.12/asyncio/__main__.py", line 58, in runcode
return future.result()
^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.12/asyncio/__main__.py", line 34, in callback
coro = func()
^^^^^^
File "<console>", line 1, in <module>
NameError: name 'x' is not defined
>>> ^D
exiting asyncio REPL...
PWD is /tmp/tmp.1fcA8GVU2A
$Expected behaviour
For x to be defined and set to 5, like in the regular non-asyncio REPL.
OS info
$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.2 LTS"
PRETTY_NAME="Ubuntu 24.04.2 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.2 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo$ uname -a
Linux ROG 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/LinuxCPython versions tested on:
3.12
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done