GNU bug report logs - #68559
[PATCH] Improve Python shell completion

Previous Next

Package: emacs;

Reported by: Liu Hui <liuhui1610 <at> gmail.com>

Date: Thu, 18 Jan 2024 04:50:01 UTC

Severity: wishlist

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: "Basil L. Contovounesios" <basil <at> contovou.net>
To: Liu Hui <liuhui1610 <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, kobarity <at> gmail.com, mattias.engdegard <at> gmail.com, 68559 <at> debbugs.gnu.org
Subject: bug#68559: [PATCH] Improve Python shell completion
Date: Tue, 20 Feb 2024 14:15:49 +0100
[Message part 1 (text/plain, inline)]
Liu Hui [2024-02-20 12:46 +0800] wrote:

> On Mon, Feb 19, 2024 at 9:18 PM Basil L. Contovounesios
> <basil <at> contovou.net> wrote:
>>
>> BTW, I have been seeing an IPython test failure on GNU/Linux:
>> Any pointers?
>
> I cannot reproduce the problem with Python 3.12 and IPython 8.21. Can
> you check the results with the following steps? Thanks.

Thanks.  These all work as expected in 'emacs -Q', which made me realise
what may be the problem:

- the Emacs test suite runs under HOME=/nonexistent
- but PATH is unchanged
- I have the latest IPython installed locally using pipx:
  $ ls -l $(which ipython)
  lrwxrwxrwx 1 blc blc 53 Feb 20 11:46
    /home/blc/.local/bin/ipython ->
      /home/blc/.local/share/pipx/venvs/ipython/bin/ipython

This is confirmed by the following experiment:

[prynt.diff (text/x-diff, inline)]
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index af6c199b5bd..3393f93542b 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -4883,6 +4883,7 @@ python-shell-completion-at-point-ipython
     (python-tests-with-temp-buffer-with-shell
      ""
      (python-shell-with-shell-buffer
+       (make-temp-file "my-py-out-" nil ".txt" (buffer-string))
        (python-shell-completion-native-turn-off)
        (python-tests--completion-module)
        (python-tests--completion-parameters)
[Message part 3 (text/plain, inline)]
Running 'make TEST_LOAD_EL=no test/python-tests' now results in the
following output file:

[my-py-out-kFh7He.txt (text/plain, inline)]
/home/blc/.local/share/pipx/venvs/ipython/lib/python3.12/site-packages/IPython/paths.py:69: UserWarning: IPython parent '/nonexistent' is not a writable location, using a temp directory.
  warn("IPython parent '{0}' is not a writable location,"
Python 3.12.2 (main, Feb 18 2024, 16:59:56) [GCC 13.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.21.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: 
[Message part 5 (text/plain, inline)]
In this case list(get_ipython().Completer.completions(...)) is empty.

I'm not sure what the best way to detect or work around this is.
Any ideas?

[ It's a problem shared, to an extent, with Eglot tests, since LSP servers are
  often installed in one's HOME. ]

Thanks,
-- 
Basil

This bug report was last modified 1 year and 66 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.