Fix __name__ != __main__ when using runpy in the osx-bundle
This commit is contained in:
@@ -53,8 +53,10 @@ static int run_embedded(const char* exe_dir_, int argc, wchar_t **argv) {
|
|||||||
if (kitty == NULL) { fprintf(stderr, "Failed to allocate python kitty lib object\n"); goto end; }
|
if (kitty == NULL) { fprintf(stderr, "Failed to allocate python kitty lib object\n"); goto end; }
|
||||||
PyObject *runpy = PyImport_ImportModule("runpy");
|
PyObject *runpy = PyImport_ImportModule("runpy");
|
||||||
if (runpy == NULL) { PyErr_Print(); fprintf(stderr, "Unable to import runpy\n"); Py_CLEAR(kitty); goto end; }
|
if (runpy == NULL) { PyErr_Print(); fprintf(stderr, "Unable to import runpy\n"); Py_CLEAR(kitty); goto end; }
|
||||||
PyObject *res = PyObject_CallMethod(runpy, "run_path", "O", kitty);
|
PyObject *run_name = PyUnicode_FromString("__main__");
|
||||||
Py_CLEAR(runpy); Py_CLEAR(kitty);
|
if (run_name == NULL) { fprintf(stderr, "Failed to allocate run_name\n"); goto end; }
|
||||||
|
PyObject *res = PyObject_CallMethod(runpy, "run_path", "OOO", kitty, Py_None, run_name);
|
||||||
|
Py_CLEAR(runpy); Py_CLEAR(kitty); Py_CLEAR(run_name);
|
||||||
if (res == NULL) PyErr_Print();
|
if (res == NULL) PyErr_Print();
|
||||||
else { ret = 0; Py_CLEAR(res); }
|
else { ret = 0; Py_CLEAR(res); }
|
||||||
end:
|
end:
|
||||||
|
|||||||
Reference in New Issue
Block a user