mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 04:22:16 +00:00
test/exec.cpp - register builtin module before call 'Py_Initialize'
This commit is contained in:
committed by
Stefan Seefeld
parent
d422058fb4
commit
bb6f52dc35
@@ -58,16 +58,6 @@ void eval_test()
|
||||
|
||||
void exec_test()
|
||||
{
|
||||
// Register the module with the interpreter
|
||||
if (PyImport_AppendInittab(const_cast<char*>("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<char*>("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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user