GNU bug report logs - #70707
30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)

Previous Next

Package: emacs;

Reported by: Lin Sun <sunlin7.mail <at> gmail.com>

Date: Wed, 1 May 2024 22:51:02 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

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

To reply to this bug, email your comments to 70707 AT debbugs.gnu.org.
There is no need to reopen the bug first.

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#70707; Package emacs. (Wed, 01 May 2024 22:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lin Sun <sunlin7.mail <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 01 May 2024 22:51:02 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7.mail <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; [PATCH] ; Check the process param in function
 (python-shell-completion-at-point)
Date: Wed, 1 May 2024 22:49:29 +0000
[Message part 1 (text/plain, inline)]
Hi,

There is an unexpected error message happening with function
`python-shell-completion-at-point`.
> Wrong type argument: processp, nil
It happened because the function does NOT check the process param.
The patch will check the param and display a user error message gracefully.

Steps to reproduce the issue.
1. $ emacs -q /tmp/a.py # start emacs and open a python source file
2. type "C-c C-p" (or M-x run-python) to start a python shell
3. type exit() to stop the python process but the buffer still exists
4. M-x python-shell-completion-at-point  will get the error message

Please help review the patch. Thanks. Regards
[0001-Check-the-process-param-in-function-python-shell-com.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70707; Package emacs. (Thu, 02 May 2024 15:37:02 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7.mail <at> gmail.com>
To: 70707 <at> debbugs.gnu.org
Subject: bug#70707: 30.0.50; [PATCH] ; Check the process param in function
 (python-shell-completion-at-point)
Date: Thu, 2 May 2024 15:36:12 +0000
Correction for step 4:
4. Switch to *python* buffer, then M-x
python-shell-completion-at-point  will get the error message




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70707; Package emacs. (Mon, 06 May 2024 00:46:02 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7.mail <at> gmail.com>
To: 70707 <at> debbugs.gnu.org, kobarity <kobarity <at> gmail.com>
Subject: Re: bug#70707: 30.0.50; [PATCH] ; Check the process param in function
 (python-shell-completion-at-point)
Date: Mon, 6 May 2024 00:44:49 +0000
> Hi,
>
> There is an unexpected error message happening with function
> `python-shell-completion-at-point`.
> > Wrong type argument: processp, nil
> It happened because the function does NOT check the process param.
> The patch will check the param and display a user error message gracefully.
>
> Steps to reproduce the issue.
> 1. $ emacs -q /tmp/a.py # start emacs and open a python source file
> 2. type "C-c C-p" (or M-x run-python) to start a python shell
> 3. type exit() to stop the python process but the buffer still exists
> 4. Switch to *python* buffer, then M-x
> python-shell-completion-at-point  will get the error message
>
> Please help review the patch. Thanks. Regards
>
>
> From aa44c95c7f13f2d68be83260e618cf4d806b313b Mon Sep 17 00:00:00 2001
> From: Lin Sun <sunlin7 <at> hotmail.com>
> Date: Wed, 1 May 2024 06:55:31 +0000
> Subject: [PATCH] ; Check the process param in function
>  (python-shell-completion-at-point)
>
> * lisp/progmodes/python.el (python-shell-completion-at-point):
>   Check the process param at the beginning of the function.
> ---
>  lisp/progmodes/python.el | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index d6c29e5ffc..4b2e2f8215 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -4708,6 +4708,8 @@ python-shell-completion-at-point
>  Optional argument PROCESS forces completions to be retrieved
>  using that one instead of current buffer's process."
>    (setq process (or process (get-buffer-process (current-buffer))))
> +  (unless process
> +    (user-error "No active python inferior process"))
>    (let* ((is-shell-buffer (derived-mode-p 'inferior-python-mode))
>           (line-start (if is-shell-buffer
>                           ;; Working on a shell buffer: use prompt end.
> --
> 2.20.5

Hi Kobarity, Please help review the patch for checking process and
emitting user-error when it's not available. Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70707; Package emacs. (Mon, 06 May 2024 15:13:02 GMT) Full text and rfc822 format available.

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

From: kobarity <kobarity <at> gmail.com>
To: Lin Sun <sunlin7.mail <at> gmail.com>
Cc: 70707 <at> debbugs.gnu.org
Subject: Re: bug#70707: 30.0.50; [PATCH] ; Check the process param in function
 (python-shell-completion-at-point)
Date: Tue, 07 May 2024 00:12:10 +0900
Lin Sun wrote:
> 
> > Hi,
> >
> > There is an unexpected error message happening with function
> > `python-shell-completion-at-point`.
> > > Wrong type argument: processp, nil
> > It happened because the function does NOT check the process param.
> > The patch will check the param and display a user error message gracefully.
> >
> > Steps to reproduce the issue.
> > 1. $ emacs -q /tmp/a.py # start emacs and open a python source file
> > 2. type "C-c C-p" (or M-x run-python) to start a python shell
> > 3. type exit() to stop the python process but the buffer still exists
> > 4. Switch to *python* buffer, then M-x
> > python-shell-completion-at-point  will get the error message
> >
> > Please help review the patch. Thanks. Regards
> >
> >
> > From aa44c95c7f13f2d68be83260e618cf4d806b313b Mon Sep 17 00:00:00 2001
> > From: Lin Sun <sunlin7 <at> hotmail.com>
> > Date: Wed, 1 May 2024 06:55:31 +0000
> > Subject: [PATCH] ; Check the process param in function
> >  (python-shell-completion-at-point)
> >
> > * lisp/progmodes/python.el (python-shell-completion-at-point):
> >   Check the process param at the beginning of the function.
> > ---
> >  lisp/progmodes/python.el | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> > index d6c29e5ffc..4b2e2f8215 100644
> > --- a/lisp/progmodes/python.el
> > +++ b/lisp/progmodes/python.el
> > @@ -4708,6 +4708,8 @@ python-shell-completion-at-point
> >  Optional argument PROCESS forces completions to be retrieved
> >  using that one instead of current buffer's process."
> >    (setq process (or process (get-buffer-process (current-buffer))))
> > +  (unless process
> > +    (user-error "No active python inferior process"))
> >    (let* ((is-shell-buffer (derived-mode-p 'inferior-python-mode))
> >           (line-start (if is-shell-buffer
> >                           ;; Working on a shell buffer: use prompt end.
> > --
> > 2.20.5
> 
> Hi Kobarity, Please help review the patch for checking process and
> emitting user-error when it's not available. Thanks.

Hi Lin,

The patch itself looks good to me.

> > 4. Switch to *python* buffer, then M-x
> > python-shell-completion-at-point  will get the error message

As `python-shell-completion-at-point' is not an interactive function,
I tested with M-x complete-symbol.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70707; Package emacs. (Mon, 06 May 2024 15:51:01 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7.mail <at> gmail.com>
To: kobarity <kobarity <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 70707 <at> debbugs.gnu.org
Subject: Re: bug#70707: 30.0.50; [PATCH] ; Check the process param in function
 (python-shell-completion-at-point)
Date: Mon, 6 May 2024 15:49:26 +0000
On Mon, May 6, 2024 at 3:12 PM kobarity <kobarity <at> gmail.com> wrote:
>
>
> Lin Sun wrote:
> >
> > > Hi,
> > >
> > > There is an unexpected error message happening with function
> > > `python-shell-completion-at-point`.
> > > > Wrong type argument: processp, nil
> > > It happened because the function does NOT check the process param.
> > > The patch will check the param and display a user error message gracefully.
> > >
> > > Steps to reproduce the issue.
> > > 1. $ emacs -q /tmp/a.py # start emacs and open a python source file
> > > 2. type "C-c C-p" (or M-x run-python) to start a python shell
> > > 3. type exit() to stop the python process but the buffer still exists
> > > 4. Switch to *python* buffer, then M-x
> > > python-shell-completion-at-point  will get the error message
> > >
> > > Please help review the patch. Thanks. Regards
> > >
> > >
> > > From aa44c95c7f13f2d68be83260e618cf4d806b313b Mon Sep 17 00:00:00 2001
> > > From: Lin Sun <sunlin7 <at> hotmail.com>
> > > Date: Wed, 1 May 2024 06:55:31 +0000
> > > Subject: [PATCH] ; Check the process param in function
> > >  (python-shell-completion-at-point)
> > >
> > > * lisp/progmodes/python.el (python-shell-completion-at-point):
> > >   Check the process param at the beginning of the function.
> > > ---
> > >  lisp/progmodes/python.el | 2 ++
> > >  1 file changed, 2 insertions(+)
> > >
> > > diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> > > index d6c29e5ffc..4b2e2f8215 100644
> > > --- a/lisp/progmodes/python.el
> > > +++ b/lisp/progmodes/python.el
> > > @@ -4708,6 +4708,8 @@ python-shell-completion-at-point
> > >  Optional argument PROCESS forces completions to be retrieved
> > >  using that one instead of current buffer's process."
> > >    (setq process (or process (get-buffer-process (current-buffer))))
> > > +  (unless process
> > > +    (user-error "No active python inferior process"))
> > >    (let* ((is-shell-buffer (derived-mode-p 'inferior-python-mode))
> > >           (line-start (if is-shell-buffer
> > >                           ;; Working on a shell buffer: use prompt end.
> > > --
> > > 2.20.5
> >
> > Hi Kobarity, Please help review the patch for checking process and
> > emitting user-error when it's not available. Thanks.
>
> Hi Lin,
>
> The patch itself looks good to me.
>
> > > 4. Switch to *python* buffer, then M-x
> > > python-shell-completion-at-point  will get the error message
>
> As `python-shell-completion-at-point' is not an interactive function,
> I tested with M-x complete-symbol.
Hi Kobarity,
Thanks for confirming! And yes, the complete-symbol is the interactive
function which will be called the `python-shell-completion-at-point'.

Hi Eli,
Please  help merge the patch. Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70707; Package emacs. (Mon, 06 May 2024 16:39:02 GMT) Full text and rfc822 format available.

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

From: Lin Sun <sunlin7.mail <at> gmail.com>
To: kobarity <kobarity <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 70707 <at> debbugs.gnu.org
Subject: Re: bug#70707: 30.0.50; [PATCH] ; Check the process param in function
 (python-shell-completion-at-point)
Date: Mon, 6 May 2024 16:37:37 +0000
Correct my previous comment: The (complete-symbol) will call the
(python-shell-completion-at-point) in python-mode.




Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Thu, 09 May 2024 08:00:02 GMT) Full text and rfc822 format available.

Notification sent to Lin Sun <sunlin7.mail <at> gmail.com>:
bug acknowledged by developer. (Thu, 09 May 2024 08:00:02 GMT) Full text and rfc822 format available.

Message #25 received at 70707-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: kobarity <kobarity <at> gmail.com>
Cc: 70707-done <at> debbugs.gnu.org, sunlin7.mail <at> gmail.com
Subject: Re: bug#70707: 30.0.50; [PATCH] ; Check the process param in function
 (python-shell-completion-at-point)
Date: Thu, 09 May 2024 10:58:30 +0300
> Cc: 70707 <at> debbugs.gnu.org
> Date: Tue, 07 May 2024 00:12:10 +0900
> From: kobarity <kobarity <at> gmail.com>
> 
> > Hi Kobarity, Please help review the patch for checking process and
> > emitting user-error when it's not available. Thanks.
> 
> Hi Lin,
> 
> The patch itself looks good to me.

Thanks, installed on master, and closing the bug.




This bug report was last modified 9 days ago.

Previous Next


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