On Wed, Mar 19, 2025 at 6:50 AM skyjudith JAI <[email protected]> wrote:

> Thank you!  Brilliant.  That worked. It's something that I (and my
> on-again off-again friend chatgpt) did not figure out.  Could you explain
> what you mean by:
> "Please never use blanket exception handling like that."  I"m not sure
> what the alternative should be.
>

What he means is that:

except Exception as e:
    print("Error during alignment:", e)


Will catch ANY exception, and then swallow it up to make it go away,
leaving you with no idea what went wrong.

So better to maybe catch, print a helpful message and then re-raise the
exception so you'll get the full stack trace.

In practice, particularly behind a GUI, there may be a need for your
program not to crash out. In that cse, you want to capture and log or
print, or something, the full traceback. Google for how, but here's a hint:

https://docs.python.org/3/library/traceback.html#module-traceback

Meanwhile, when debugging, you definitely simply want the Exception to
bubble up :-)

-CHB







>
> Judith
>
>
> On Tue, Mar 18, 2025 at 3:04 PM bwoodsend <[email protected]> wrote:
>
>> If you remove the try/except, the cause is fairly standard.
>> Traceback (most recent call last): File "astroalign.py", line 537, in
>> _find_sources File "sep_pjw.pyx", line 21, in init sep_pjw
>> ModuleNotFoundError: No module named '_version' During handling of the
>> above exception, another exception occurred: Traceback (most recent call
>> last): File "simple_align.py", line 25, in <module> transform, footprint
>> = aa.find_transform(target_image, ref_image)
>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "astroalign.py", line 314,
>> in find_transform TypeError: Input type for source not supported. [PYI-
>> 1439842:ERROR] Failed to execute script 'simple_align' due to unhandled
>> exception!
>>
>> The fix is just to add --hiddenimport=_version to the build command.
>> (I’d call it a bug in sep_pjw that it’s keeping its version in a top
>> level module rather than say sep_pjw._version but that’s another matter.)
>>
>> Please never use blanket exception handling like that. We’d have fixed
>> this in about 2 seconds if you hadn’t thrown away the stacktrace.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyInstaller" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion visit
>> https://groups.google.com/d/msgid/pyinstaller/e7b80820-9007-4996-bf86-53caf60ebdc5n%40googlegroups.com
>> <https://groups.google.com/d/msgid/pyinstaller/e7b80820-9007-4996-bf86-53caf60ebdc5n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "PyInstaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion visit
> https://groups.google.com/d/msgid/pyinstaller/CABuiZsh_QkqU6241bpb8_L%2BrZWP2F7PaseY91bKHq6_9v5L%3DTw%40mail.gmail.com
> <https://groups.google.com/d/msgid/pyinstaller/CABuiZsh_QkqU6241bpb8_L%2BrZWP2F7PaseY91bKHq6_9v5L%3DTw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/pyinstaller/CALGmxEKuPVcvtDnCF5dDySj_HER2LAZv%2B7fW5drUg5zA%3DDbmxw%40mail.gmail.com.

Reply via email to