Subject: bug#75729: [PATCH v3] python-mode: add `exit` to the list of block-enders

From: kobarity <[email-masked]>
Date: Thu, 23 Jan 2025 01:01:26 +0900

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) "("))))