unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)
@ 2024-05-01 22:49 Lin Sun
  2024-05-02 15:36 ` Lin Sun
  0 siblings, 1 reply; 7+ messages in thread
From: Lin Sun @ 2024-05-01 22:49 UTC (permalink / raw)
  To: 70707

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

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

[-- Attachment #2: 0001-Check-the-process-param-in-function-python-shell-com.patch --]
[-- Type: text/x-patch, Size: 1100 bytes --]

From aa44c95c7f13f2d68be83260e618cf4d806b313b Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)
  2024-05-01 22:49 bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point) Lin Sun
@ 2024-05-02 15:36 ` Lin Sun
  2024-05-06  0:44   ` Lin Sun
  0 siblings, 1 reply; 7+ messages in thread
From: Lin Sun @ 2024-05-02 15:36 UTC (permalink / raw)
  To: 70707

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





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)
  2024-05-02 15:36 ` Lin Sun
@ 2024-05-06  0:44   ` Lin Sun
  2024-05-06 15:12     ` kobarity
  0 siblings, 1 reply; 7+ messages in thread
From: Lin Sun @ 2024-05-06  0:44 UTC (permalink / raw)
  To: 70707, kobarity

> 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@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)
  2024-05-06  0:44   ` Lin Sun
@ 2024-05-06 15:12     ` kobarity
  2024-05-06 15:49       ` Lin Sun
  2024-05-09  7:58       ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: kobarity @ 2024-05-06 15:12 UTC (permalink / raw)
  To: Lin Sun; +Cc: 70707


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@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)
  2024-05-06 15:12     ` kobarity
@ 2024-05-06 15:49       ` Lin Sun
  2024-05-06 16:37         ` Lin Sun
  2024-05-09  7:58       ` Eli Zaretskii
  1 sibling, 1 reply; 7+ messages in thread
From: Lin Sun @ 2024-05-06 15:49 UTC (permalink / raw)
  To: kobarity, Eli Zaretskii; +Cc: 70707

On Mon, May 6, 2024 at 3:12 PM kobarity <kobarity@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@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)
  2024-05-06 15:49       ` Lin Sun
@ 2024-05-06 16:37         ` Lin Sun
  0 siblings, 0 replies; 7+ messages in thread
From: Lin Sun @ 2024-05-06 16:37 UTC (permalink / raw)
  To: kobarity, Eli Zaretskii; +Cc: 70707

Correct my previous comment: The (complete-symbol) will call the
(python-shell-completion-at-point) in python-mode.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point)
  2024-05-06 15:12     ` kobarity
  2024-05-06 15:49       ` Lin Sun
@ 2024-05-09  7:58       ` Eli Zaretskii
  1 sibling, 0 replies; 7+ messages in thread
From: Eli Zaretskii @ 2024-05-09  7:58 UTC (permalink / raw)
  To: kobarity; +Cc: 70707-done, sunlin7.mail

> Cc: 70707@debbugs.gnu.org
> Date: Tue, 07 May 2024 00:12:10 +0900
> From: kobarity <kobarity@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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-09  7:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01 22:49 bug#70707: 30.0.50; [PATCH] ; Check the process param in function (python-shell-completion-at-point) Lin Sun
2024-05-02 15:36 ` Lin Sun
2024-05-06  0:44   ` Lin Sun
2024-05-06 15:12     ` kobarity
2024-05-06 15:49       ` Lin Sun
2024-05-06 16:37         ` Lin Sun
2024-05-09  7:58       ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).