Skip to content

Commit a75f444

Browse files
kobarityskangas
authored andcommitted
Improve completion in IPython/Python 3.13
IPython/Python 3.13 indirectly imports rlcompleter, and the completer is set up to reference rlcompleter.__main__. However, this rlcompleter.__main__ is different from the __main__ in the REPL execution. Therefore, this completer cannot correctly complete the REPL globals. To address this issue, we override rlcompleter.__main__ with __main__ only in the case of IPython. * lisp/progmodes/python.el (python-shell-completion-native-setup): Modify __PYTHON_EL_native_completion_setup(). (Bug#76205)
1 parent c180966 commit a75f444

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lisp/progmodes/python.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4537,6 +4537,13 @@ def __PYTHON_EL_native_completion_setup():
45374537
if not is_ipython:
45384538
readline.set_completer(new_completer)
45394539
else:
4540+
# Ensure that rlcompleter.__main__ and __main__ are identical.
4541+
# (Bug#76205)
4542+
import sys
4543+
try:
4544+
sys.modules['rlcompleter'].__main__ = sys.modules['__main__']
4545+
except KeyError:
4546+
pass
45404547
# Try both initializations to cope with all IPython versions.
45414548
# This works fine for IPython 3.x but not for earlier:
45424549
readline.set_completer(new_completer)

0 commit comments

Comments
 (0)