diff --git a/test/exec.cpp b/test/exec.cpp index 9fb005ea..72ff571b 100644 --- a/test/exec.cpp +++ b/test/exec.cpp @@ -58,16 +58,6 @@ void eval_test() void exec_test() { - // Register the module with the interpreter - if (PyImport_AppendInittab(const_cast("embedded_hello"), -#if PY_VERSION_HEX >= 0x03000000 - PyInit_embedded_hello -#else - initembedded_hello -#endif - ) == -1) - throw std::runtime_error("Failed to add embedded_hello to the interpreter's " - "builtin modules"); // Retrieve the main module python::object main = python::import("__main__"); @@ -152,6 +142,20 @@ int main(int argc, char **argv) { BOOST_TEST(argc == 2 || argc == 3); std::string script = argv[1]; + + // Register the module with the interpreter + if (PyImport_AppendInittab(const_cast("embedded_hello"), +#if PY_VERSION_HEX >= 0x03000000 + PyInit_embedded_hello +#else + initembedded_hello +#endif + ) == -1) + { + BOOST_ERROR("Failed to add embedded_hello to the interpreter's " + "builtin modules"); + } + // Initialize the interpreter Py_Initialize();