]>
Commit | Line | Data |
---|---|---|
54675d1f JR |
1 | Index: blender-2.80_patched/source/blender/python/generic/py_capi_utils.c |
2 | =================================================================== | |
3 | --- blender-2.80_patched/source/blender/python/generic/py_capi_utils.c | |
4 | +++ blender-2.80_patched/source/blender/python/generic/py_capi_utils.c | |
5 | @@ -717,9 +717,11 @@ | |
6 | ****************************************************************************/ | |
7 | PyObject *PyC_DefaultNameSpace(const char *filename) | |
8 | { | |
9 | - PyInterpreterState *interp = PyThreadState_GET()->interp; | |
10 | + PyObject *modules = PyImport_GetModuleDict(); | |
11 | + PyObject *builtins = PyDict_GetItemString(modules, "builtins"); | |
12 | + | |
13 | PyObject *mod_main = PyModule_New("__main__"); | |
14 | - PyDict_SetItemString(interp->modules, "__main__", mod_main); | |
15 | + PyDict_SetItemString(modules, "__main__", mod_main); | |
16 | Py_DECREF(mod_main); /* sys.modules owns now */ | |
17 | PyModule_AddStringConstant(mod_main, "__name__", "__main__"); | |
18 | if (filename) { | |
19 | @@ -727,8 +729,8 @@ | |
20 | * note: this wont map to a real file when executing text-blocks and buttons. */ | |
21 | PyModule_AddObject(mod_main, "__file__", PyC_UnicodeFromByte(filename)); | |
22 | } | |
23 | - PyModule_AddObject(mod_main, "__builtins__", interp->builtins); | |
24 | - Py_INCREF(interp->builtins); /* AddObject steals a reference */ | |
25 | + PyModule_AddObject(mod_main, "__builtins__", builtins); | |
26 | + Py_INCREF(builtins); /* AddObject steals a reference */ | |
27 | return PyModule_GetDict(mod_main); | |
28 | } | |
29 | ||
30 | @@ -755,15 +757,15 @@ | |
31 | /* restore MUST be called after this */ | |
32 | void PyC_MainModule_Backup(PyObject **main_mod) | |
33 | { | |
34 | - PyInterpreterState *interp = PyThreadState_GET()->interp; | |
35 | - *main_mod = PyDict_GetItemString(interp->modules, "__main__"); | |
36 | + PyObject *modules = PyImport_GetModuleDict(); | |
37 | + *main_mod = PyDict_GetItemString(modules, "__main__"); | |
38 | Py_XINCREF(*main_mod); /* don't free */ | |
39 | } | |
40 | ||
41 | void PyC_MainModule_Restore(PyObject *main_mod) | |
42 | { | |
43 | - PyInterpreterState *interp = PyThreadState_GET()->interp; | |
44 | - PyDict_SetItemString(interp->modules, "__main__", main_mod); | |
45 | + PyObject *modules = PyImport_GetModuleDict(); | |
46 | + PyDict_SetItemString(modules, "__main__", main_mod); | |
47 | Py_XDECREF(main_mod); | |
48 | } | |
49 |