Skip to content
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: return 1 if frozen python script exits due to exception #5481

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion bootloader/src/pyi_launch.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,10 @@ pyi_launch_run_scripts(ARCHIVE_STATUS *status)
}
#endif /* if defined(WINDOWED) and defined(LAUNCH_DEBUG) */

return -1;
/* Be consistent with python interpreter, which returns
* 1 if it exits due to unhandled exception.
*/
return 1;
}
free(data);
}
Expand Down
3 changes: 3 additions & 0 deletions news/5480.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix the return code if the frozen script fails due to unhandled exception.
The return code 1 is used instead of -1, to keep the behavior consistent
with that of the python interpreter.
3 changes: 2 additions & 1 deletion tests/unit/test_systemexit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
('import sys; sys.exit()', 0),
('raise SystemExit(1)', 1),
('import sys; sys.exit(2)', 2),
('raise SystemExit("Message to get printed to the console.")', 1)
('raise SystemExit("Message to get printed to the console.")', 1),
('raise Exception("Unhandled exception.")', 1) # See issue #5480
]
)
def test_systemexit_is_handled_correctly(src, retcode, pyi_builder):
Expand Down