diff options
-rw-r--r-- | source/blender/python/generic/bpy_internal_import.c | 6 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 5 | ||||
-rw-r--r-- | source/gameengine/Expressions/PyObjectPlus.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/GameLogic/SCA_PythonController.cpp | 9 |
4 files changed, 4 insertions, 19 deletions
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 96fe13bf6fc..cb145cc453b 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -34,9 +34,6 @@ #include <Python.h> #include <stddef.h> -#include "compile.h" /* for the PyCodeObject */ -#include "eval.h" /* for PyEval_EvalCode */ - #include "bpy_internal_import.h" #include "MEM_guardedalloc.h" @@ -51,7 +48,6 @@ /* UNUSED */ #include "BKE_text.h" /* txt_to_buf */ #include "BKE_main.h" -#include "BKE_global.h" /* grr, only for G.main->name */ static Main *bpy_import_main= NULL; @@ -97,7 +93,7 @@ void bpy_import_main_set(struct Main *maggie) /* returns a dummy filename for a textblock so we can tell what file a text block comes from */ void bpy_text_filename_get(char *fn, size_t fn_len, Text *text) { - BLI_snprintf(fn, fn_len, "%s%c%s", text->id.lib ? text->id.lib->filepath : G.main->name, SEP, text->id.name+2); + BLI_snprintf(fn, fn_len, "%s%c%s", text->id.lib ? text->id.lib->filepath : bpy_import_main->name, SEP, text->id.name+2); } PyObject *bpy_text_import(Text *text) diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 8b361de17fa..72d391fed32 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -5882,7 +5882,6 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun PyObject *py_class= (PyObject*)py_data; PyObject *base_class= RNA_struct_py_type_get(srna); PyObject *item; - PyObject *py_arg_count; int i, flag, arg_count, func_arg_count; const char *py_class_name= ((PyTypeObject *)py_class)->tp_name; // __name__ @@ -5945,9 +5944,7 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun func_arg_count= rna_function_arg_count(func); if (func_arg_count >= 0) { /* -1 if we dont care*/ - py_arg_count= PyObject_GetAttrString(PyFunction_GET_CODE(item), "co_argcount"); - arg_count= PyLong_AsLong(py_arg_count); - Py_DECREF(py_arg_count); + arg_count= ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount; /* note, the number of args we check for and the number of args we give to * @classmethods are different (quirk of python), this is why rna_function_arg_count() doesn't return the value -1*/ diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 65c20cad518..10906cdae02 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -1198,14 +1198,13 @@ void PyDebugLine() f_lineno= PyObject_GetAttrString(frame, "f_lineno"); f_code= PyObject_GetAttrString(frame, "f_code"); if (f_lineno && f_code) { - co_filename= PyObject_GetAttrString(f_code, "co_filename"); + co_filename= ((PyCodeObject *)f_code)->co_filename; /* borrow */ if (co_filename) { printf("\t%s:%d\n", _PyUnicode_AsString(co_filename), (int)PyLong_AsSsize_t(f_lineno)); Py_DECREF(f_lineno); Py_DECREF(f_code); - Py_DECREF(co_filename); Py_DECREF(frame); return; } diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index d0c1155de96..19ddce13757 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -357,14 +357,7 @@ bool SCA_PythonController::Import() m_function_argc = 0; /* rare cases this could be a function that isnt defined in python, assume zero args */ if (PyFunction_Check(m_function)) { - PyObject *py_arg_count = PyObject_GetAttrString(PyFunction_GET_CODE(m_function), "co_argcount"); - if(py_arg_count) { - m_function_argc = PyLong_AsLong(py_arg_count); - Py_DECREF(py_arg_count); - } - else { - PyErr_Clear(); /* unlikely to fail but just incase */ - } + m_function_argc= ((PyCodeObject *)PyFunction_GET_CODE(m_function))->co_argcount; } if(m_function_argc > 1) { |