GNU bug report logs -
#75729
[PATCH] python-mode: add `exit` to the list of block-enders
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75729 in the body.
You can then email your comments to 75729 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 15:43:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 21 Jan 2025 15:43:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
`exit()` ends current codeflow, there can't be any code past it. So
account `exit` similarly to `return`, `continue`, etc.
[1.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 15:49:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 75729 <at> debbugs.gnu.org (full text, mbox):
> From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> Date: Tue, 21 Jan 2025 18:41:54 +0300
>
>
> `exit()` ends current codeflow, there can't be any code past it. So
> account `exit` similarly to `return`, `continue`, etc.
>
> From 7806987dd88b2507d97255c2e6ca989e791c798b Mon Sep 17 00:00:00 2001
> From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> Date: Tue, 21 Jan 2025 18:34:54 +0300
> Subject: [PATCH] python-mode: add `exit` to the list of block-enders
>
> `exit()` ends current codeflow, there can't be any code past it. So
> account `exit` similarly to `return`, `continue`, etc.
>
> * /lisp/progmodes/python.el (python-rx): add `exit` to the list of
> block-enders.
This should start with a capital letter (to be a complete sentence).
> ---
> lisp/progmodes/python.el | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 16c296a8f86..2feb9f47e1a 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -442,7 +442,8 @@ python-rx
> symbol-end))
> (block-ender (seq symbol-start
> (or
> - "break" "continue" "pass" "raise" "return")
> + "break" "continue" "pass" "raise" "return"
> + "exit")
> symbol-end))
> (decorator (seq line-start (* space) ?@ (any letter ?_)
> (* (any word ?_))))
> --
> 2.48.1
>
Thanks. kobarity, any comments?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 15:50:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 75729 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Do you want to consider more of the terminal calls? os.exit() os._exit()
sys.exit() quit() (though quit raises SystemExit which could be locally
caught; I think it's equivalent to raise SystemExit?).
On Tue, Jan 21, 2025 at 10:43 AM Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
wrote:
> `exit()` ends current codeflow, there can't be any code past it. So
> account `exit` similarly to `return`, `continue`, etc.
>
>
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 15:56:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 75729 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, 2025-01-21 at 10:47 -0500, Ship Mints wrote:
> Do you want to consider more of the terminal calls? os.exit()
> os._exit() sys.exit() quit() (though quit raises SystemExit which
> could be locally caught; I think it's equivalent to raise
> SystemExit?).
>
> On Tue, Jan 21, 2025 at 10:43 AM Konstantin Kharlamov
> <Hi-Angel <at> yandex.ru> wrote:
> > `exit()` ends current codeflow, there can't be any code past it. So
> > account `exit` similarly to `return`, `continue`, etc.
Good point, thank you! I changed the patch to account for `quit` as
well.
If this is acceptable, I'd prefer to be light on the changes here and
only account for exit and quit for now because it's very simple to
support 😊
Also fixed the commit message per Eli's comment.
[1.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 15:57:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 75729 <at> debbugs.gnu.org (full text, mbox):
On Tue, 2025-01-21 at 17:48 +0200, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> > Date: Tue, 21 Jan 2025 18:41:54 +0300
> >
> >
> > `exit()` ends current codeflow, there can't be any code past it. So
> > account `exit` similarly to `return`, `continue`, etc.
> >
> > From 7806987dd88b2507d97255c2e6ca989e791c798b Mon Sep 17 00:00:00
> > 2001
> > From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> > Date: Tue, 21 Jan 2025 18:34:54 +0300
> > Subject: [PATCH] python-mode: add `exit` to the list of block-
> > enders
> >
> > `exit()` ends current codeflow, there can't be any code past it. So
> > account `exit` similarly to `return`, `continue`, etc.
> >
> > * /lisp/progmodes/python.el (python-rx): add `exit` to the list of
> > block-enders.
>
> This should start with a capital letter (to be a complete sentence).
Thank you! Fixed in the v2 sent in reply to Ship's email 😊
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 18:54:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 75729 <at> debbugs.gnu.org (full text, mbox):
Konstantin Kharlamov <Hi-Angel <at> yandex.ru> writes:
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 16c296a8f86..2feb9f47e1a 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -442,7 +442,8 @@ python-rx
> symbol-end))
> (block-ender (seq symbol-start
> (or
> - "break" "continue" "pass" "raise" "return")
> + "break" "continue" "pass" "raise" "return"
> + "exit")
> symbol-end))
> (decorator (seq line-start (* space) ?@ (any letter ?_)
> (* (any word ?_))))
> --
> 2.48.1
Could you describe what behaviour changes this will result in?
I recommend something brief about that to the commit message too.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 19:01:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 75729 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, 2025-01-21 at 10:52 -0800, Stefan Kangas wrote:
> Konstantin Kharlamov <Hi-Angel <at> yandex.ru> writes:
>
> > diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> > index 16c296a8f86..2feb9f47e1a 100644
> > --- a/lisp/progmodes/python.el
> > +++ b/lisp/progmodes/python.el
> > @@ -442,7 +442,8 @@ python-rx
> > symbol-end))
> > (block-ender (seq symbol-start
> > (or
> > - "break" "continue" "pass"
> > "raise" "return")
> > + "break" "continue" "pass"
> > "raise" "return"
> > + "exit")
> > symbol-end))
> > (decorator (seq line-start (* space) ?@ (any
> > letter ?_)
> > (* (any word ?_))))
> > --
> > 2.48.1
>
> Could you describe what behaviour changes this will result in?
>
> I recommend something brief about that to the commit message too.
Thank you, done! I put the following text to the commit message, please
see if it describes the change well enough:
> `exit()` and `quit()` end the current codeflow, there can't be any
> code past it, similarly to `return`, `continue`, etc. So when
> calculating indentation for the line next to `exit()` and `quit()`,
> decrease the indentation level.
Patch is attached.
[1.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Tue, 21 Jan 2025 19:43:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 75729 <at> debbugs.gnu.org (full text, mbox):
Konstantin Kharlamov <Hi-Angel <at> yandex.ru> writes:
> On Tue, 2025-01-21 at 10:52 -0800, Stefan Kangas wrote:
>
>> Could you describe what behaviour changes this will result in?
>>
>> I recommend something brief about that to the commit message too.
>
> Thank you, done! I put the following text to the commit message, please
> see if it describes the change well enough:
Thanks!
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Wed, 22 Jan 2025 16:02:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 75729 <at> debbugs.gnu.org (full text, mbox):
Ship Mints wrote:
> Do you want to consider more of the terminal calls? os.exit() os._exit()
> sys.exit() quit() (though quit raises SystemExit which could be locally
> caught; I think it's equivalent to raise SystemExit?).
I too would prefer to include these. Because I think `sys.exit()` is
recommended over `exit().
https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-sys-exit.html
Another point is that although `exit()` ends current codeflow, `exit`
does not end current codeflow. This is where it differs from
`return`, etc.
This is a bit complicated, but how about the following code?
(block-ender (seq
symbol-start
(or
(seq (or
"break" "continue" "pass" "raise" "return")
symbol-end)
(seq
(or
(seq (? (or (seq "os." (? ?_)) "sys.")) "exit")
"quit") (* space) "("))))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Wed, 22 Jan 2025 20:52:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 75729 <at> debbugs.gnu.org (full text, mbox):
kobarity <kobarity <at> gmail.com> writes:
> This is a bit complicated, but how about the following code?
>
> (block-ender (seq
> symbol-start
> (or
> (seq (or
> "break" "continue" "pass" "raise" "return")
> symbol-end)
> (seq
> (or
> (seq (? (or (seq "os." (? ?_)) "sys.")) "exit")
> "quit") (* space) "("))))
LGTM.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Wed, 22 Jan 2025 22:13:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 75729 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thu, 2025-01-23 at 01:01 +0900, kobarity wrote:
>
> Ship Mints wrote:
> > Do you want to consider more of the terminal calls? os.exit()
> > os._exit()
> > sys.exit() quit() (though quit raises SystemExit which could be
> > locally
> > caught; I think it's equivalent to raise SystemExit?).
>
> I too would prefer to include these. Because I think `sys.exit()` is
> recommended over `exit().
>
> https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-sys-exit.html
>
> Another point is that although `exit()` ends current codeflow, `exit`
> does not end current codeflow. This is where it differs from
> `return`, etc.
>
> This is a bit complicated, but how about the following code?
>
> (block-ender (seq
> symbol-start
> (or
> (seq (or
> "break" "continue" "pass"
> "raise" "return")
> symbol-end)
> (seq
> (or
> (seq (? (or (seq "os." (? ?_))
> "sys.")) "exit")
> "quit") (* space) "("))))
Thank you, I replaced the code and tested it, it works for me. I did a
small change though: I moved the `(* space…` part on the new line to
align it with `(or …)`. In the older code it looked like this text is
part of the `(or …)` expression. But please see if it's okay this way,
you definitely have more ELisp experience 😊
[1.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Thu, 23 Jan 2025 15:12:02 GMT)
Full text and
rfc822 format available.
Message #38 received at 75729 <at> debbugs.gnu.org (full text, mbox):
Konstantin Kharlamov wrote:
> On Thu, 2025-01-23 at 01:01 +0900, kobarity wrote:
> >
> > Ship Mints wrote:
> > > Do you want to consider more of the terminal calls? os.exit()
> > > os._exit()
> > > sys.exit() quit() (though quit raises SystemExit which could be
> > > locally
> > > caught; I think it's equivalent to raise SystemExit?).
> >
> > I too would prefer to include these. Because I think `sys.exit()` is
> > recommended over `exit().
> >
> > https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-sys-exit.html
> >
> > Another point is that although `exit()` ends current codeflow, `exit`
> > does not end current codeflow. This is where it differs from
> > `return`, etc.
> >
> > This is a bit complicated, but how about the following code?
> >
> > (block-ender (seq
> > symbol-start
> > (or
> > (seq (or
> > "break" "continue" "pass"
> > "raise" "return")
> > symbol-end)
> > (seq
> > (or
> > (seq (? (or (seq "os." (? ?_))
> > "sys.")) "exit")
> > "quit") (* space) "("))))
>
> Thank you, I replaced the code and tested it, it works for me. I did a
> small change though: I moved the `(* space…` part on the new line to
> align it with `(or …)`. In the older code it looked like this text is
> part of the `(or …)` expression. But please see if it's okay this way,
> you definitely have more ELisp experience 😊
Thanks, it looks good to me.
Severity set to 'wishlist' from 'normal'
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 25 Jan 2025 00:19:02 GMT)
Full text and
rfc822 format available.
Reply sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
You have taken responsibility.
(Sat, 25 Jan 2025 10:55:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
:
bug acknowledged by developer.
(Sat, 25 Jan 2025 10:55:02 GMT)
Full text and
rfc822 format available.
Message #45 received at 75729-done <at> debbugs.gnu.org (full text, mbox):
> From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Kangas <stefankangas <at> gmail.com>,
> 75729 <at> debbugs.gnu.org
> Date: Thu, 23 Jan 2025 01:12:32 +0300
>
> On Thu, 2025-01-23 at 01:01 +0900, kobarity wrote:
> >
> > Ship Mints wrote:
> > > Do you want to consider more of the terminal calls? os.exit()
> > > os._exit()
> > > sys.exit() quit() (though quit raises SystemExit which could be
> > > locally
> > > caught; I think it's equivalent to raise SystemExit?).
> >
> > I too would prefer to include these. Because I think `sys.exit()` is
> > recommended over `exit().
> >
> > https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-sys-exit.html
> >
> > Another point is that although `exit()` ends current codeflow, `exit`
> > does not end current codeflow. This is where it differs from
> > `return`, etc.
> >
> > This is a bit complicated, but how about the following code?
> >
> > (block-ender (seq
> > symbol-start
> > (or
> > (seq (or
> > "break" "continue" "pass"
> > "raise" "return")
> > symbol-end)
> > (seq
> > (or
> > (seq (? (or (seq "os." (? ?_))
> > "sys.")) "exit")
> > "quit") (* space) "("))))
>
> Thank you, I replaced the code and tested it, it works for me. I did a
> small change though: I moved the `(* space…` part on the new line to
> align it with `(or …)`. In the older code it looked like this text is
> part of the `(or …)` expression. But please see if it's okay this way,
> you definitely have more ELisp experience 😊
Thanks, installed on the master branch, and closing the bug.
Please in the future always mention the bug number (when known) in the
commit log message.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75729
; Package
emacs
.
(Sat, 25 Jan 2025 11:05:01 GMT)
Full text and
rfc822 format available.
Message #48 received at 75729-done <at> debbugs.gnu.org (full text, mbox):
On Sat, 2025-01-25 at 12:54 +0200, Eli Zaretskii wrote:
> > From: Konstantin Kharlamov <Hi-Angel <at> yandex.ru>
> > Cc: Eli Zaretskii <eliz <at> gnu.org>, Stefan Kangas
> > <stefankangas <at> gmail.com>,
> > 75729 <at> debbugs.gnu.org
> > Date: Thu, 23 Jan 2025 01:12:32 +0300
> >
> > On Thu, 2025-01-23 at 01:01 +0900, kobarity wrote:
> > >
> > > Ship Mints wrote:
> > > > Do you want to consider more of the terminal calls? os.exit()
> > > > os._exit()
> > > > sys.exit() quit() (though quit raises SystemExit which could be
> > > > locally
> > > > caught; I think it's equivalent to raise SystemExit?).
> > >
> > > I too would prefer to include these. Because I think
> > > `sys.exit()` is
> > > recommended over `exit().
> > >
> > > https://pylint.readthedocs.io/en/latest/user_guide/messages/refactor/consider-using-sys-exit.html
> > >
> > > Another point is that although `exit()` ends current codeflow,
> > > `exit`
> > > does not end current codeflow. This is where it differs from
> > > `return`, etc.
> > >
> > > This is a bit complicated, but how about the following code?
> > >
> > > (block-ender (seq
> > > symbol-start
> > > (or
> > > (seq (or
> > > "break" "continue" "pass"
> > > "raise" "return")
> > > symbol-end)
> > > (seq
> > > (or
> > > (seq (? (or (seq "os." (? ?_))
> > > "sys.")) "exit")
> > > "quit") (* space) "("))))
> >
> > Thank you, I replaced the code and tested it, it works for me. I
> > did a
> > small change though: I moved the `(* space…` part on the new line
> > to
> > align it with `(or …)`. In the older code it looked like this text
> > is
> > part of the `(or …)` expression. But please see if it's okay this
> > way,
> > you definitely have more ELisp experience 😊
>
> Thanks, installed on the master branch, and closing the bug.
>
> Please in the future always mention the bug number (when known) in
> the
> commit log message.
Thank you, I'll try to remember 😊 A lot of things to keep in mind
regarding commit messages in the project, I wish Savannah git would
provide a CI that would automatically check such things…
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 22 Feb 2025 12:24:19 GMT)
Full text and
rfc822 format available.
This bug report was last modified today.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.