[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#64406: [PATCH] Improve commands to manage Python imports
From: |
Augusto Stoffel |
Subject: |
bug#64406: [PATCH] Improve commands to manage Python imports |
Date: |
Fri, 07 Jul 2023 19:02:27 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
On Sat, 1 Jul 2023 at 22:16, Matthias Meulien wrote:
> -from sys import argv, stdin
> +from sys import argv, exit, stdin
FWIW, exit is already in the global namespace.
> - (unless (eq 0 status)
> + (cond
> + ((eq 1 status)
> (error "%s exited with status %s (maybe isort is missing?)"
> python-interpreter status))
> + ((eq 2 status)
> + (error "%s exited with status %s (maybe isort version is <5.7.0?)"
> + python-interpreter status)))
This change implies that the "success" branch may run if the exit code
is nonzero (without knowing all the isort internals, it can't be
excluded that an exit code > 2 is used somewhere). I suggest instead a
(pcase status ...) to construct the " (maybe... ?)" segment of the error
message.
We could also take this opportunity to distinguish between random
exceptions happening in the script (which likely leads to exit code 1)
and the ModuleNotFoundError case.