From 4898e57bdd247f1f2a18ca1217a89e7f1105caae Mon Sep 17 00:00:00 2001 From: "Aaron L. Zeng" Date: Tue, 12 Jul 2022 01:05:04 -0400 Subject: Fix SIGABRT when python subcommand raises an exception Before, `ledger python -- -c 'raise RuntimeError'` would terminate messily via SIGABRT, printing the following: terminate called after throwing an instance of 'int' [1] 2151711 abort (core dumped) ledger python -c 'raise RuntimeError' This change makes the python subcommand throw a standard C++ exception rather than just a plain int, which is never caught and triggers the SIGABRT. Now, the process prints the uncaught Python exception as usual and then exits with exit code 1. --- src/pyinterp.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pyinterp.cc b/src/pyinterp.cc index f4d664cf..2c549890 100644 --- a/src/pyinterp.cc +++ b/src/pyinterp.cc @@ -376,8 +376,9 @@ value_t python_interpreter_t::python_command(call_scope_t& args) delete[] argv[i]; delete[] argv; - if (status != 0) - throw status; + if (status != 0) { + throw_(std::runtime_error, _("Failed to execute Python module")); + } return NULL_VALUE; } -- cgit v1.2.3