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:
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/generic/bgl.c2
-rw-r--r--source/blender/python/generic/blf_api.c2
-rw-r--r--source/blender/python/generic/bpy_internal_import.c2
-rw-r--r--source/blender/python/generic/geometry.c2
-rw-r--r--source/blender/python/generic/mathutils.c2
-rw-r--r--source/blender/python/generic/noise.c2
-rw-r--r--source/blender/python/intern/bpy.c2
-rw-r--r--source/blender/python/intern/bpy_operator.c4
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c4
-rw-r--r--source/blender/python/intern/bpy_props.c2
-rw-r--r--source/blender/python/intern/bpy_rna.c6
-rw-r--r--source/blender/python/intern/bpy_util.c26
-rw-r--r--source/blender/python/intern/bpy_util.h2
13 files changed, 38 insertions, 20 deletions
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index bb0b3a43186..8ac2107f8d2 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -1117,7 +1117,7 @@ PyObject *BGL_Init(void)
{
PyObject *mod, *dict, *item;
mod = PyModule_Create(&BGL_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), BGL_module_def.m_name, mod);
+ PyDict_SetItemString(PyImport_GetModuleDict(), BGL_module_def.m_name, mod);
dict= PyModule_GetDict(mod);
if( PyType_Ready( &BGL_bufferType) < 0)
diff --git a/source/blender/python/generic/blf_api.c b/source/blender/python/generic/blf_api.c
index 011a0c217c8..a5f5f8815c7 100644
--- a/source/blender/python/generic/blf_api.c
+++ b/source/blender/python/generic/blf_api.c
@@ -394,7 +394,7 @@ PyObject *BLF_Init(void)
PyObject *submodule;
submodule = PyModule_Create(&BLF_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), BLF_module_def.m_name, submodule);
+ PyDict_SetItemString(PyImport_GetModuleDict(), BLF_module_def.m_name, submodule);
PyModule_AddIntConstant(submodule, "ROTATION", BLF_ROTATION);
PyModule_AddIntConstant(submodule, "CLIPPING", BLF_CLIPPING);
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 0bcecafd23c..1951e72567c 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -304,7 +304,7 @@ PyMethodDef bpy_reload_meth[] = { {"bpy_reload_meth", (PyCFunction)blender_reloa
void bpy_text_clear_modules(int clear_all)
{
- PyObject *modules= PySys_GetObject("modules");
+ PyObject *modules= PyImport_GetModuleDict();
char *fname;
char *file_extension;
diff --git a/source/blender/python/generic/geometry.c b/source/blender/python/generic/geometry.c
index 1e8436ed5ae..0e98760314d 100644
--- a/source/blender/python/generic/geometry.c
+++ b/source/blender/python/generic/geometry.c
@@ -835,7 +835,7 @@ PyObject *Geometry_Init(void)
PyObject *submodule;
submodule = PyModule_Create(&M_Geometry_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), M_Geometry_module_def.m_name, submodule);
+ PyDict_SetItemString(PyImport_GetModuleDict(), M_Geometry_module_def.m_name, submodule);
return (submodule);
}
diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c
index ada5bac8c2a..a643e6621b2 100644
--- a/source/blender/python/generic/mathutils.c
+++ b/source/blender/python/generic/mathutils.c
@@ -258,7 +258,7 @@ PyObject *Mathutils_Init(void)
return NULL;
submodule = PyModule_Create(&M_Mathutils_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), M_Mathutils_module_def.m_name, submodule);
+ PyDict_SetItemString(PyImport_GetModuleDict(), M_Mathutils_module_def.m_name, submodule);
/* each type has its own new() function */
PyModule_AddObject( submodule, "Vector", (PyObject *)&vector_Type );
diff --git a/source/blender/python/generic/noise.c b/source/blender/python/generic/noise.c
index b07950099a3..4a09cbb58d8 100644
--- a/source/blender/python/generic/noise.c
+++ b/source/blender/python/generic/noise.c
@@ -658,7 +658,7 @@ static struct PyModuleDef noise_module_def = {
PyObject *Noise_Init(void)
{
PyObject *submodule = PyModule_Create(&noise_module_def);
- PyDict_SetItemString(PySys_GetObject("modules"), noise_module_def.m_name, submodule);
+ PyDict_SetItemString(PyImport_GetModuleDict(), noise_module_def.m_name, submodule);
/* use current time as seed for random number generator by default */
setRndSeed(0);
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 1336a752b22..e107509d844 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -163,7 +163,7 @@ void BPy_init_modules( void )
mod = PyModule_New("_bpy");
/* add the module so we can import it */
- PyDict_SetItemString(PySys_GetObject("modules"), "_bpy", mod);
+ PyDict_SetItemString(PyImport_GetModuleDict(), "_bpy", mod);
Py_DECREF(mod);
/* run first, initializes rna types */
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 0e54f158ac4..c6c34fbcaf5 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -63,7 +63,7 @@ static PyObject *pyop_call( PyObject * self, PyObject * args)
if (!PyArg_ParseTuple(args, "sO|O!s:_bpy.ops.call", &opname, &context_dict, &PyDict_Type, &kw, &context_str))
return NULL;
- ot= WM_operatortype_exists(opname);
+ ot= WM_operatortype_find(opname, TRUE);
if (ot == NULL) {
PyErr_Format( PyExc_SystemError, "Calling operator \"bpy.ops.%s\" error, could not be found", opname);
@@ -259,7 +259,7 @@ PyObject *BPY_operator_module( void )
static PyMethodDef pyop_macro_def_meth ={"macro_define", (PyCFunction) PYOP_wrap_macro_define, METH_VARARGS, NULL};
PyObject *submodule = PyModule_New("_bpy.ops");
- PyDict_SetItemString(PySys_GetObject("modules"), "_bpy.ops", submodule);
+ PyDict_SetItemString(PyImport_GetModuleDict(), "_bpy.ops", submodule);
PyModule_AddObject( submodule, "call", PyCFunction_New(&pyop_call_meth, NULL) );
PyModule_AddObject( submodule, "as_string",PyCFunction_New(&pyop_as_string_meth,NULL) );
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index 0c1eafb4948..1e521aea438 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -105,7 +105,7 @@ PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", &macro, &opname))
return NULL;
- if (WM_operatortype_exists(opname) == NULL) {
+ if (WM_operatortype_find(opname, TRUE) == NULL) {
PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid operator id", opname);
return NULL;
}
@@ -114,7 +114,7 @@ PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args)
srna= srna_from_self(macro, "Macro Define:");
macroname = RNA_struct_identifier(srna);
- ot = WM_operatortype_exists(macroname);
+ ot = WM_operatortype_find(macroname, TRUE);
if (!ot) {
PyErr_Format(PyExc_ValueError, "Macro Define: '%s' is not a valid macro or hasn't been registered yet", macroname);
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index c278ad56ab9..9afe638908c 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -919,7 +919,7 @@ PyObject *BPY_rna_props( void )
{
PyObject *submodule;
submodule= PyModule_Create(&props_module);
- PyDict_SetItemString(PySys_GetObject("modules"), props_module.m_name, submodule);
+ PyDict_SetItemString(PyImport_GetModuleDict(), props_module.m_name, submodule);
/* INCREF since its its assumed that all these functions return the
* module with a new ref like PyDict_New, since they are passed to
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 9b2248d1ed4..05ccabe1641 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -63,11 +63,11 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_
/* bpyrna vector/euler/quat callbacks */
static int mathutils_rna_array_cb_index= -1; /* index for our callbacks */
-/* not used yet but may want to use the subtype below */
+/* subtype not used much yet */
#define MATHUTILS_CB_SUBTYPE_EUL 0
#define MATHUTILS_CB_SUBTYPE_VEC 1
#define MATHUTILS_CB_SUBTYPE_QUAT 2
-#define MATHUTILS_CB_SUBTYPE_COLOR 0
+#define MATHUTILS_CB_SUBTYPE_COLOR 3
static int mathutils_rna_generic_check(BaseMathObject *bmo)
{
@@ -3130,8 +3130,6 @@ static struct PyMethodDef pyrna_prop_methods[] = {
};
static struct PyMethodDef pyrna_prop_array_methods[] = {
- {"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL},
- {"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c
index 38462d1b176..1d14ab67510 100644
--- a/source/blender/python/intern/bpy_util.c
+++ b/source/blender/python/intern/bpy_util.c
@@ -54,7 +54,7 @@ void PyObSpit(char *name, PyObject *var) {
}
void PyLineSpit(void) {
- char *filename;
+ const char *filename;
int lineno;
PyErr_Clear();
@@ -63,7 +63,7 @@ void PyLineSpit(void) {
fprintf(stderr, "%s:%d\n", filename, lineno);
}
-void BPY_getFileAndNum(char **filename, int *lineno)
+void BPY_getFileAndNum(const char **filename, int *lineno)
{
PyObject *getframe, *frame;
PyObject *f_lineno= NULL, *co_filename= NULL;
@@ -83,6 +83,7 @@ void BPY_getFileAndNum(char **filename, int *lineno)
return;
}
+ /* when executing a script */
if (filename) {
co_filename= PyObject_GetAttrStringArgs(frame, 1, "f_code", "co_filename");
if (co_filename==NULL) {
@@ -95,6 +96,25 @@ void BPY_getFileAndNum(char **filename, int *lineno)
Py_DECREF(co_filename);
}
+ /* when executing a module */
+ if(filename && *filename == NULL) {
+ /* try an alternative method to get the filename - module based
+ * references below are all borrowed (double checked) */
+ PyObject *mod_name= PyDict_GetItemString(PyEval_GetGlobals(), "__name__");
+ if(mod_name) {
+ PyObject *mod= PyDict_GetItem(PyImport_GetModuleDict(), mod_name);
+ if(mod) {
+ *filename= PyModule_GetFilename(mod);
+ }
+
+ /* unlikely, fallback */
+ if(*filename == NULL) {
+ *filename= _PyUnicode_AsString(mod_name);
+ }
+ }
+ }
+
+
if (lineno) {
f_lineno= PyObject_GetAttrString(frame, "f_lineno");
if (f_lineno==NULL) {
@@ -330,7 +350,7 @@ int BPy_errors_to_report(ReportList *reports)
PyObject *pystring_format= NULL; // workaround, see below
char *cstring;
- char *filename;
+ const char *filename;
int lineno;
if (!PyErr_Occurred())
diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h
index e7e7bb09419..cfe820b53b0 100644
--- a/source/blender/python/intern/bpy_util.h
+++ b/source/blender/python/intern/bpy_util.h
@@ -38,7 +38,7 @@ struct ReportList;
void PyObSpit(char *name, PyObject *var);
void PyLineSpit(void);
-void BPY_getFileAndNum(char **filename, int *lineno);
+void BPY_getFileAndNum(const char **filename, int *lineno);
PyObject *BPY_exception_buffer(void);