bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64406: [PATCH] Improve commands to manage Python imports


From: Matthias Meulien
Subject: bug#64406: [PATCH] Improve commands to manage Python imports
Date: Fri, 07 Jul 2023 19:46:00 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Augusto Stoffel <arstoffel@gmail.com> writes:

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

Yes but it isn't meant for use in programs; The documentation says:

    The *note site module (which is imported automatically during startup,
    except if the -S command-line option is given) adds several
    constants to the built-in namespace.  They are useful for the
    interactive interpreter shell and should not be used in programs.


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

Thanks, I'll fix this.

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

Good point, I'll improve this too.
-- 
Matthias





reply via email to

[Prev in Thread] Current Thread [Next in Thread]