Since ipython 8.18 already merged https://github.com/ipython/ipython/pull/14241, this workaround is no longer necessary. Moreover, the workaround gives a deprecation warning in python 3.12.
This PR uses the test sys.modules['IPython'].version_info < (8, 18, 0, '') to apply the workaround only in older ipython.
In case the IPython module is not loaded this will raiseKeyErrorand correctlyreturn Falsethanks to theexcept BaseException` already there.
Since ipython 8.18 already merged https://github.com/ipython/ipython/pull/14241, this workaround is no longer necessary. Moreover, the workaround gives a deprecation warning in python 3.12.
This PR uses the test
sys.modules['IPython'].version_info < (8, 18, 0, '')
to apply the workaround only in older ipython.In case the IPython module is not loaded this will
raise
KeyErrorand correctly
return Falsethanks to the
except BaseException` already there.See: https://github.com/prompt-toolkit/python-prompt-toolkit/pull/1811#issuecomment-1827043359
Cc: @jonathanslenders