svn merge -r 31314:31370 https://svn.blender.org/svnroot/bf-blender/trunk/blender
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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) );
|
||||
|
||||
@@ -105,7 +105,7 @@ PyObject *PYOP_wrap_macro_define(PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", ¯o, &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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
};
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user