Unhandled exception in event loop when using IPython with prompt_toolkit 3.0.51 on WSL (Python 3.10 via uv)
- Dominant language
- Python
- Stars
- 16.8k
- Forks
- 4.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 6
Description
Hi ipython team,
I'm encountering an issue when running IPython in a WSL environment on Windows. Although commands execute successfully, I consistently receive the following error message after each command:
```text
Unhandled exception in event loop:
File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/uv-env/lib/python3.10/site-packages/prompt_toolkit/input/vt100.py", line 162, in callback_wrapper
callback()
File "/uv-env/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 714, in read_from_input_in_context
context.copy().run(read_from_input)
File "/uv-env/lib/python3.10/site-packages/prompt_toolkit/application/application.py", line 694, in read_from_input
self.key_processor.process_keys()
File "/uv-env/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 273, in process_keys
self._process_coroutine.send(key_press)
File "/uv-env/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 188, in _process
self._call_handler(matches[-1], key_sequence=buffer[:])
File "/uv-env/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_processor.py", line 323, in _call_handler
handler.call(event)
File "/uv-env/lib/python3.10/site-packages/prompt_toolkit/key_binding/key_bindings.py", line 127, in call
result = self.handler(event)
File "/uv-env/lib/python3.10/site-packages/IPython/terminal/shortcuts/__init__.py", line 405, in handle_return_or_newline_or_execute
return newline_or_execute_outer(shell)(event)
File "/uv-env/lib/python3.10/site-packages/IPython/terminal/shortcuts/__init__.py", line 428, in newline_or_execute
status, indent = shell.check_complete(check_text)
File "/uv-env/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3626, in check_complete
status, nspaces = self.input_transformer_manager.check_complete(code)
File "/uv-env/lib/python3.10/site-packages/IPython/core/inputtransformer2.py", line 721, in check_complete
if lines[0].startswith('%%'):
```
### Environment
- OS: Windows 11 (via WSL2 - Ubuntu)
- Python: 3.10.13 (installed via pyenv)
- Environment Manager: uv
- prompt_toolkit: 3.0.51
- IPython: 8.37.0
- Terminal: Windows Terminal
### Steps to Reproduce
1. Create a new environment using uv with Python 3.10.12
2. Install ipython and prompt_toolkit==3.0.51.
3. Launch IPython and run any command (e.g., 1 + 1).
4. Observe the unhandled exception in the terminal output.
## Notes
The error does not prevent commands from executing.
Any guidance or workaround would be appreciated. Happy to provide more details!
Contributor guide
Assessment
This issue has not been assessed yet.