diff --git a/gnucash/gnucash-commands.cpp b/gnucash/gnucash-commands.cpp index 2f94a056530..d0849092726 100644 --- a/gnucash/gnucash-commands.cpp +++ b/gnucash/gnucash-commands.cpp @@ -614,11 +614,17 @@ run_python_cli (int argc, char **argv, scripting_args* args) PINFO ("Running python script %s...", script_filename); auto fp = fopen (script_filename, "rb"); if (!fp) + { std::cerr << bl::format (_("Unable to load Python script {1}")) % script_filename << std::endl; + python_cleanup (config, status); + } else if (PyRun_SimpleFileEx (fp, script_filename, 1) != 0) + { std::cerr << bl::format (_("Python script {1} execution failed.")) % script_filename << std::endl; + python_cleanup (config, status); + } } if (args->interactive) {