diff options
author | Aaron L. Zeng <me@bcc32.com> | 2022-07-12 01:05:04 -0400 |
---|---|---|
committer | Martin Michlmayr <tbm@cyrius.com> | 2022-07-13 13:08:50 +0800 |
commit | 4898e57bdd247f1f2a18ca1217a89e7f1105caae (patch) | |
tree | 4ead4f1ae42da47241e3ae48af675e72c68b045a /src/pyinterp.cc | |
parent | bf1684d63d950823e6f4ff91bae649e28a6c5fdf (diff) | |
download | fork-ledger-4898e57bdd247f1f2a18ca1217a89e7f1105caae.tar.gz fork-ledger-4898e57bdd247f1f2a18ca1217a89e7f1105caae.tar.bz2 fork-ledger-4898e57bdd247f1f2a18ca1217a89e7f1105caae.zip |
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.
Diffstat (limited to 'src/pyinterp.cc')
-rw-r--r-- | src/pyinterp.cc | 5 |
1 files changed, 3 insertions, 2 deletions
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; } |