GNU bug report logs - #77853
30.1; python-inferior-mode: completion regression

Previous Next

Package: emacs;

Reported by: Christian Sattler <sattler.christian <at> gmail.com>

Date: Wed, 16 Apr 2025 23:44:03 UTC

Severity: normal

Found in version 30.1

To reply to this bug, email your comments to 77853 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#77853; Package emacs. (Wed, 16 Apr 2025 23:44:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christian Sattler <sattler.christian <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 16 Apr 2025 23:44:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christian Sattler <sattler.christian <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.1; python-inferior-mode: completion regression
Date: Wed, 16 Apr 2025 21:59:01 +0200
Completing a non-existing prefix attempts to complete it as a filename.

Steps to reproduce:

1. touch test.file
2. emacs -Q
3. M-x run-python
4. test
5. M-x python-shell-completion-complete-or-indent

Outcome: incorrectly completes to test.file.

This regression was introduced in commit 0b9c714. The function
python-shell-completion-at-point now returns nil instead of an empty
list of candidates. This causes the next element of
completion-at-point-functions list to be tried. This is
comint-completion-at-point and completes filenames, which does not
make sense in this context.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77853; Package emacs. (Thu, 17 Apr 2025 06:31:02 GMT) Full text and rfc822 format available.

Message #8 received at 77853 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Christian Sattler <sattler.christian <at> gmail.com>,
 Liu Hui <liuhui1610 <at> gmail.com>, kobarity <kobarity <at> gmail.com>
Cc: 77853 <at> debbugs.gnu.org
Subject: Re: bug#77853: 30.1; python-inferior-mode: completion regression
Date: Thu, 17 Apr 2025 09:29:41 +0300
> From: Christian Sattler <sattler.christian <at> gmail.com>
> Date: Wed, 16 Apr 2025 21:59:01 +0200
> 
> Completing a non-existing prefix attempts to complete it as a filename.
> 
> Steps to reproduce:
> 
> 1. touch test.file
> 2. emacs -Q
> 3. M-x run-python
> 4. test
> 5. M-x python-shell-completion-complete-or-indent
> 
> Outcome: incorrectly completes to test.file.
> 
> This regression was introduced in commit 0b9c714. The function
> python-shell-completion-at-point now returns nil instead of an empty
> list of candidates. This causes the next element of
> completion-at-point-functions list to be tried. This is
> comint-completion-at-point and completes filenames, which does not
> make sense in this context.

Thanks.

Liu Hui and kobarity, any suggestions for how to fix that?  The fix
should be safe enough for the release branch, since the regression was
introduced by Emacs 30.1.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77853; Package emacs. (Fri, 18 Apr 2025 05:39:04 GMT) Full text and rfc822 format available.

Message #11 received at 77853 <at> debbugs.gnu.org (full text, mbox):

From: Liu Hui <liuhui1610 <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 77853 <at> debbugs.gnu.org, Christian Sattler <sattler.christian <at> gmail.com>,
 kobarity <kobarity <at> gmail.com>
Subject: Re: bug#77853: 30.1; python-inferior-mode: completion regression
Date: Fri, 18 Apr 2025 13:38:04 +0800
[Message part 1 (text/plain, inline)]
On Thu, Apr 17, 2025 at 2:29 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> > From: Christian Sattler <sattler.christian <at> gmail.com>
> > Date: Wed, 16 Apr 2025 21:59:01 +0200
> >
> > Completing a non-existing prefix attempts to complete it as a filename.
> >
> > Steps to reproduce:
> >
> > 1. touch test.file
> > 2. emacs -Q
> > 3. M-x run-python
> > 4. test
> > 5. M-x python-shell-completion-complete-or-indent
> >
> > Outcome: incorrectly completes to test.file.
> >
> > This regression was introduced in commit 0b9c714. The function
> > python-shell-completion-at-point now returns nil instead of an empty
> > list of candidates. This causes the next element of
> > completion-at-point-functions list to be tried. This is
> > comint-completion-at-point and completes filenames, which does not
> > make sense in this context.
>
> Thanks.
>
> Liu Hui and kobarity, any suggestions for how to fix that?  The fix
> should be safe enough for the release branch, since the regression was
> introduced by Emacs 30.1.

We can just remove comint-filename-completion from
comint-dynamic-complete-functions, which is called by
comint-completion-at-point in completion-at-point-functions.

Before commit 0b9c714, comint-filename-completion was actually not
used due to python-shell-completion-at-point. Therefore, removing it
is safe and acceptable.

Users who need proper filename completion in Python shell can use
specialized completion backends, e.g.

1. touch test.file
2. export PYTHONSTARTUP="$(python -m jedi repl)"; emacs -Q
3. M-x run-python
4. test<tab>         => no completion
5. open("test<tab>   => open("test.file"
[0001-Fix-filename-completion-in-Python-shell-bug-77853.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77853; Package emacs. (Sun, 20 Apr 2025 15:13:01 GMT) Full text and rfc822 format available.

Message #14 received at 77853 <at> debbugs.gnu.org (full text, mbox):

From: kobarity <kobarity <at> gmail.com>
To: Liu Hui <liuhui1610 <at> gmail.com>
Cc: 77853 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Christian Sattler <sattler.christian <at> gmail.com>
Subject: Re: bug#77853: 30.1; python-inferior-mode: completion regression
Date: Mon, 21 Apr 2025 00:12:03 +0900
Liu Hui wrote:
> On Thu, Apr 17, 2025 at 2:29 PM Eli Zaretskii <eliz <at> gnu.org> wrote:
> >
> > > From: Christian Sattler <sattler.christian <at> gmail.com>
> > > Date: Wed, 16 Apr 2025 21:59:01 +0200
> > >
> > > Completing a non-existing prefix attempts to complete it as a filename.
> > >
> > > Steps to reproduce:
> > >
> > > 1. touch test.file
> > > 2. emacs -Q
> > > 3. M-x run-python
> > > 4. test
> > > 5. M-x python-shell-completion-complete-or-indent
> > >
> > > Outcome: incorrectly completes to test.file.
> > >
> > > This regression was introduced in commit 0b9c714. The function
> > > python-shell-completion-at-point now returns nil instead of an empty
> > > list of candidates. This causes the next element of
> > > completion-at-point-functions list to be tried. This is
> > > comint-completion-at-point and completes filenames, which does not
> > > make sense in this context.
> >
> > Thanks.
> >
> > Liu Hui and kobarity, any suggestions for how to fix that?  The fix
> > should be safe enough for the release branch, since the regression was
> > introduced by Emacs 30.1.
> 
> We can just remove comint-filename-completion from
> comint-dynamic-complete-functions, which is called by
> comint-completion-at-point in completion-at-point-functions.
> 
> Before commit 0b9c714, comint-filename-completion was actually not
> used due to python-shell-completion-at-point. Therefore, removing it
> is safe and acceptable.
> 
> Users who need proper filename completion in Python shell can use
> specialized completion backends, e.g.
> 
> 1. touch test.file
> 2. export PYTHONSTARTUP="$(python -m jedi repl)"; emacs -Q
> 3. M-x run-python
> 4. test<tab>         => no completion
> 5. open("test<tab>   => open("test.file"

I agree with this patch, but it failed to apply to both master and
emacs-30 branches.  Is this patch for the latest branch?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77853; Package emacs. (Mon, 21 Apr 2025 04:59:01 GMT) Full text and rfc822 format available.

Message #17 received at 77853 <at> debbugs.gnu.org (full text, mbox):

From: Liu Hui <liuhui1610 <at> gmail.com>
To: kobarity <kobarity <at> gmail.com>
Cc: 77853 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Christian Sattler <sattler.christian <at> gmail.com>
Subject: Re: bug#77853: 30.1; python-inferior-mode: completion regression
Date: Mon, 21 Apr 2025 12:58:27 +0800
[Message part 1 (text/plain, inline)]
On Sun, Apr 20, 2025 at 11:12 PM kobarity <kobarity <at> gmail.com> wrote:
>
> I agree with this patch, but it failed to apply to both master and
> emacs-30 branches.  Is this patch for the latest branch?

Sorry, I didn't test it. Please try the attached patch.
[0001-Fix-filename-completion-in-Python-shell-bug-77853.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#77853; Package emacs. (Mon, 21 Apr 2025 14:11:01 GMT) Full text and rfc822 format available.

Message #20 received at 77853 <at> debbugs.gnu.org (full text, mbox):

From: kobarity <kobarity <at> gmail.com>
To: Liu Hui <liuhui1610 <at> gmail.com>
Cc: 77853 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Christian Sattler <sattler.christian <at> gmail.com>
Subject: Re: bug#77853: 30.1; python-inferior-mode: completion regression
Date: Mon, 21 Apr 2025 23:10:15 +0900
Liu Hui wrote:
> On Sun, Apr 20, 2025 at 11:12 PM kobarity <kobarity <at> gmail.com> wrote:
> >
> > I agree with this patch, but it failed to apply to both master and
> > emacs-30 branches.  Is this patch for the latest branch?
> 
> Sorry, I didn't test it. Please try the attached patch.

Thanks a lot.  I have applied the patch and confirmed that it works as
expected.




This bug report was last modified 2 days ago.

Previous Next


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