Repository navigation
test_repl.test_toplevel_contextvars_async fails under Fish in a VS Code terminal #137569
Copy link
Copy link
Closed
Closed
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-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:
This is on VS Code insiders on Windows with a checkout in WSL.
➲ ./python -m test test_repl
Using random seed: 506736770
0:00:00 load avg: 0.01 Run 1 test sequentially in a single process
0:00:00 load avg: 0.01 [1/1] test_repl
test test_repl failed -- Traceback (most recent call last):
File "/home/brett/Repositories/python/cpython/Lib/test/test_repl.py", line 339, in test_toplevel_contextvars_async
self.assertIn(expected, output, expected)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 'toplevel contextvar test: ok' not found in 'asyncio REPL 3.15.0a0 (heads/main-dirty:d7dbde89588, Aug 8 2025, 14:49:47) [Clang 14.0.6 ] on linux\nUse "await" directly instead of "asyncio.run()".\nType "help", "copyright", "credits" or "license" for more information.\nException in thread Interactive thread:\nexiting asyncio REPL...\nTraceback (most recent call last):\nTraceback (most recent call last):\n File "/home/brett/Repositories/python/cpython/Lib/runpy.py", line 198, in _run_module_as_main\n return _run_code(code, main_globals, None,\n "__main__", mod_spec)\n File "/home/brett/Repositories/python/cpython/Lib/threading.py", line 1074, in _bootstrap_inner\n self._context.run(self.run)\n ~~~~~~~~~~~~~~~~~^^^^^^^^^^\n File "/home/brett/Repositories/python/cpython/Lib/asyncio/__main__.py", line 105, in run\n exec(startup_code, console.locals)\n ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/home/brett/.vscode-server-insiders/data/User/workspaceStorage/0abd4bd2132dfcbfde5adbe8d7792ee2/ms-python.python/pythonrc.py", line 5, in <module>\n import readline\nModuleNotFoundError: No module named \'readline\'\n File "/home/brett/Repositories/python/cpython/Lib/runpy.py", line 88, in _run_code\n exec(code, run_globals)\n ~~~~^^^^^^^^^^^^^^^^^^^\n File "/home/brett/Repositories/python/cpython/Lib/asyncio/__main__.py", line 245, in <module>\n sys.exit(return_code)\n ~~~~~~~~^^^^^^^^^^^^^\nSystemExit: 0\n>>> >>> >>> ... File "<stdin>", line 2\n await set_var()\n ^^^^^\nSyntaxError: invalid syntax\n>>> toplevel contextvar test: failed\n>>> \n' : toplevel contextvar test: ok
0:00:00 load avg: 0.17 [1/1/1] test_repl failed (1 failure)
== Tests result: FAILURE ==
1 test failed:
test_repl
Total duration: 846 ms
Total tests: run=13 failures=1
Total test files: run=1/1 failed=1
Result: FAILURE
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
johnslavik commentedon Oct 18, 2025
I wrote that test -- will take a look at it.
johnslavik commentedon Oct 18, 2025
Oh, it's in the traceback.
where
sis:The asyncio REPL tries to import
readlinein a startup file and exits as part of #140287 that I've reported today independently, and then it spawns a regular REPL because the interpreter was run with the-iflag.Wow, what an interesting coincidence.
The easiest workaround is to have
readlineavailable or remove it from yourPYTHONSTARTUP.The fundamental question is why do we launch 2 REPLs in this test... (filed #140298 to fix)
johnslavik commentedon Oct 18, 2025
@brettcannon This is just an instance of #140287. The asyncio REPL can work without readline, but you're trying to import readline in your startup file (
/home/brett/.vscode-server-insiders/data/User/workspaceStorage/0abd4bd2132dfcbfde5adbe8d7792ee2/ms-python.python/pythonrc.py), it's unavailable, and the asyncio REPL doesn't handlePYTHONSTARTUPfailures properly.johnslavik commentedon Oct 18, 2025
@ZeroIntensity (mentorship): Should we close this as duplicate or wait until the root issue is resolved and then close this afterwards?
ZeroIntensity commentedon Oct 18, 2025
This doesn't look like an exact copy of #140287, so let's keep this open for now.