-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bootloader: only print "failed to execute" error on non-SystemExit errors #4907
bootloader: only print "failed to execute" error on non-SystemExit errors #4907
Conversation
5320125
to
9ebe325
Compare
Stuff to do:
|
9ebe325
to
4dd7c10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bootloader/src/pyi_python.c
Outdated
GETPROC(dll, PyImport_AddModule); | ||
GETPROC(dll, PyImport_ExecCodeModule); | ||
GETPROC(dll, PyImport_ImportModule); | ||
GETPROC(dll, PyList_Append); | ||
GETPROC(dll, PyList_New); | ||
GETPROC(dll, PyLong_AsLong); | ||
// GETPROC(dll, PyLong_Check); | ||
GETPROC(dll, PyModule_GetDict); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I add this in, the bootloader doesn't run. Any ideas? Same for the other commented out line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for struggling with C :-)
I'm curious about the intention of _handle_system_exit
. AFAIU this will terminate the program without traceback if and only if the exception was SystemExit(), SystemExit(0) or SystemExit(None). Esp. the will not terminate on e.g. SystemExit(1), but print the traceback!?
If this understanding is correct, this behaves quite different then the python interpreter and as the non-windows case - which both suppress the traceback on any SystemExit(…).
Also AFAIU this function's purpose is to avoid fetching ptype, pvalue and ptraceback twice. I would not spend code on this optimization, since this only occurs in debug-mod and only if an unexpected error occurs and while the program is terminating anyway.
To summarize: Why not just call PI_PyErr_Print
instead of _handle_system_exit
? (And if so: Move it above the #if defined(WINDOWED) …
)
Another idea to simplify the code: The reason for the added // scratch
stderr = PySys_GetObject("__stderr__");
PySys_SetObject("stderr", stderr);
PI_PyErr_Print(); This of course requires |
:-( This will not work, as
|
4dd7c10
to
43edf06
Compare
@htgoebel I had an idea last night :-). I've moved the PI_PyErr_Print();
FATALERROR("Failed to execute...");
#if defined(WINDOWED) && defined(LAUNCH_DEBUG)
// Windowed traceback
#endif My rationale for this change is that when running in windowed mode the |
Top! |
#4592 added a new traceback to the bootloader. That caused an error that was originally reported and fixed in #1869 and 36b6ab3. The error was that
SystemExit
- the standard script exit exception, raised bysys.exit
and other exit functions, was handled as a normal exception, and the bootloader printedFailed to execute script X
, before erroring.This PR fixes this by checking if this error is a SystemExit first.
Fixes #4860