explicit calls instead of PyRun_SimpleString

This commit is contained in:
David Rose 2009-08-28 17:59:27 +00:00
parent 0ad1e310d3
commit 15175c727d

View File

@ -137,11 +137,23 @@ run_python() {
return false; return false;
} }
string startup; // We need the "imp" built-in module for that.
startup = "import imp; imp.load_dynamic('libpandaexpress', \""; PyObject *imp_module = PyImport_ImportModule("imp");
startup += libpandaexpress.to_os_specific(); if (imp_module == NULL) {
startup += "\");"; PyErr_Print();
PyRun_SimpleString(startup.c_str()); return false;
}
string os_specific = libpandaexpress.to_os_specific();
PyObject *result = PyObject_CallMethod
(imp_module, (char *)"load_dynamic", (char *)"ss",
"libpandaexpress", os_specific.c_str());
if (result == NULL) {
PyErr_Print();
return false;
}
Py_DECREF(result);
Py_DECREF(imp_module);
// Now we can load _vfsimporter.pyd. Since this is a magic frozen // Now we can load _vfsimporter.pyd. Since this is a magic frozen
// pyd, importing it automatically makes all of its frozen contents // pyd, importing it automatically makes all of its frozen contents
@ -161,7 +173,7 @@ run_python() {
} }
// And register the VFSImporter. // And register the VFSImporter.
PyObject *result = PyObject_CallMethod(vfsimporter_module, (char *)"register", (char *)""); result = PyObject_CallMethod(vfsimporter_module, (char *)"register", (char *)"");
if (result == NULL) { if (result == NULL) {
PyErr_Print(); PyErr_Print();
return false; return false;