aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2019-04-17 11:12:58 +0100
committerDavid Shah <dave@ds0.me>2019-04-17 11:12:58 +0100
commit9fa13b5adcb4bfb193645fee0091c5c51c88c17b (patch)
treebaf69b152e1d3f6397e27f4d0889f43e0b6b512a /common
parentede81dc095b4766e3771a59bb71536e769e12c42 (diff)
downloadnextpnr-9fa13b5adcb4bfb193645fee0091c5c51c88c17b.tar.gz
nextpnr-9fa13b5adcb4bfb193645fee0091c5c51c88c17b.tar.bz2
nextpnr-9fa13b5adcb4bfb193645fee0091c5c51c88c17b.zip
pybindings: make errors in Python scripts stop nextpnr execution
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r--common/pybindings.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/common/pybindings.cc b/common/pybindings.cc
index f8f366cf..60f87e27 100644
--- a/common/pybindings.cc
+++ b/common/pybindings.cc
@@ -23,6 +23,7 @@
#include "pybindings.h"
#include "arch_pybindings.h"
#include "jsonparse.h"
+#include "log.h"
#include "nextpnr.h"
#include <boost/filesystem.hpp>
@@ -267,12 +268,15 @@ void execute_python_file(const char *python_file)
fprintf(stderr, "Fatal error: file not found %s\n", python_file);
exit(1);
}
- PyRun_SimpleFile(fp, python_file);
+ int result = PyRun_SimpleFile(fp, python_file);
fclose(fp);
+ if (result == -1) {
+ log_error("Error occurred while executing Python script %s\n", python_file);
+ }
} catch (boost::python::error_already_set const &) {
// Parse and output the exception
std::string perror_str = parse_python_exception();
- std::cout << "Error in Python: " << perror_str << std::endl;
+ log_error("Error in Python: %s\n", perror_str.c_str());
}
}