Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-29 20:12:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-03-29 20:12:25 +0400
commitf4ba9495c506f462fcad1c7db4d8fa2aae147a6f (patch)
tree3fdb8aef60b9187e898f6de6a64495b5aa1e7a98 /source/blender
parentc0ab420a73d51ff7f8fc2bb305128dfbb57ac487 (diff)
fix [#26667] Can't import scripts when using blenderplayer
- move import override initialization to bpy_internal_import.c so the player and blender can both call. - remove ineffectual & unused sandboxing code.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/python/generic/bpy_internal_import.c21
-rw-r--r--source/blender/python/generic/bpy_internal_import.h2
-rw-r--r--source/blender/python/intern/bpy_interface.c22
3 files changed, 24 insertions, 21 deletions
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index f4d88b33a48..0ea4e083e3e 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -55,6 +55,27 @@
static Main *bpy_import_main= NULL;
+/* 'builtins' is most likely PyEval_GetBuiltins() */
+void bpy_import_init(PyObject *builtins)
+{
+ PyObject *item;
+ PyObject *mod;
+
+ PyDict_SetItemString(builtins, "__import__", item=PyCFunction_New(&bpy_import_meth, NULL)); Py_DECREF(item);
+
+ /* move reload here
+ * XXX, use import hooks */
+ mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
+ if(mod) {
+ PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
+ Py_DECREF(mod);
+ }
+ else {
+ BLI_assert(!"unable to load 'imp' module.");
+ }
+}
+
+
static void free_compiled_text(Text *text)
{
if(text->compiled) {
diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h
index 7aabdcf3bf2..0ef31229f8d 100644
--- a/source/blender/python/generic/bpy_internal_import.h
+++ b/source/blender/python/generic/bpy_internal_import.h
@@ -47,6 +47,8 @@
struct Text;
+void bpy_import_init(PyObject *builtins);
+
PyObject* bpy_text_import(struct Text *text);
PyObject* bpy_text_import_name(char *name, int *found);
PyObject* bpy_text_reimport(PyObject *module, int *found);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 8833079d742..c6b442fd930 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -272,27 +272,7 @@ void BPY_python_start(int argc, const char **argv)
/* bpy.* and lets us import it */
BPy_init_modules();
- { /* our own import and reload functions */
- PyObject *item;
- PyObject *mod;
- //PyObject *m= PyImport_AddModule("__builtin__");
- //PyObject *d= PyModule_GetDict(m);
- PyObject *d= PyEval_GetBuiltins();
-// PyDict_SetItemString(d, "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
- PyDict_SetItemString(d, "__import__", item=PyCFunction_New(&bpy_import_meth, NULL)); Py_DECREF(item);
-
- /* move reload here
- * XXX, use import hooks */
- mod= PyImport_ImportModuleLevel((char *)"imp", NULL, NULL, NULL, 0);
- if(mod) {
- PyDict_SetItemString(PyModule_GetDict(mod), "reload", item=PyCFunction_New(&bpy_reload_meth, NULL)); Py_DECREF(item);
- Py_DECREF(mod);
- }
- else {
- BLI_assert(!"unable to load 'imp' module.");
- }
-
- }
+ bpy_import_init(PyEval_GetBuiltins());
pyrna_alloc_types();