diff options
| author | kobarity | 2025-02-16 19:07:04 +0900 |
|---|---|---|
| committer | Stefan Kangas | 2025-02-18 20:04:16 +0100 |
| commit | a75f4449fa2aceab54f28c5ef46f82225376c2a4 (patch) | |
| tree | 6b6684eb88f93f70d2f0af3ebe389299764133db /lisp/progmodes/python.el | |
| parent | c180966b313c87fd8a3a48218340b48ac0b933f2 (diff) | |
| download | emacs-a75f4449fa2aceab54f28c5ef46f82225376c2a4.tar.gz emacs-a75f4449fa2aceab54f28c5ef46f82225376c2a4.zip | |
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)
Diffstat (limited to 'lisp/progmodes/python.el')
| -rw-r--r-- | lisp/progmodes/python.el | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index a42e2b2a28a..2dc0441bd47 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -4537,6 +4537,13 @@ def __PYTHON_EL_native_completion_setup(): | |||
| 4537 | if not is_ipython: | 4537 | if not is_ipython: |
| 4538 | readline.set_completer(new_completer) | 4538 | readline.set_completer(new_completer) |
| 4539 | else: | 4539 | 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 | ||
| 4540 | # Try both initializations to cope with all IPython versions. | 4547 | # Try both initializations to cope with all IPython versions. |
| 4541 | # This works fine for IPython 3.x but not for earlier: | 4548 | # This works fine for IPython 3.x but not for earlier: |
| 4542 | readline.set_completer(new_completer) | 4549 | readline.set_completer(new_completer) |