Open auxsvr opened 6 months ago
This is intentional. IPython used to pass the input hook by setting an event loop which we can use in prompt_toolkit.
The if _called_from_ipython():
test that we have there is a workaround to ensure that %gui
keeps working in older IPython versions. Merging this would break those IPython versions.
We can remove the elif _called_from_ipython():
block entirely when everyone who's using the newest prompt_toolkit also uses the newest IPython. Or we should check the IPython version in the called_from_ipython()
function and return False
for the newer IPython versions.
Feel free to create a PR that does that.
asyncio.get_event_loop
is already deprecated and may not return the running loop, cf. https://github.com/python/cpython/issues/96377#issuecomment-1260006538. According to the discussion there, it should be replaced with asyncio.get_running_loop
or the corresponding policy method. If the loop
on line 988 is the running loop, this should not break old versions (newer than Python 3.7), if I understand the purpose of this code correctly. Of course, as I am not familiar with the codebase, I could be wrong.
If I am wrong, please explain. At the moment, using asyncio.get_running_loop
looks like the easiest option to me, preserving backward compatibility.
The latter is deprecated and may not always return the running event loop.
Resolves https://github.com/prompt-toolkit/python-prompt-toolkit/issues/1824.