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:
-rw-r--r--source/blender/python/BPY_interface.c9
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp14
2 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c
index 29ef6c5da1d..dfcf6aa35a5 100644
--- a/source/blender/python/BPY_interface.c
+++ b/source/blender/python/BPY_interface.c
@@ -616,7 +616,12 @@ static void BPY_Err_Handle( char *script_name )
}
Py_DECREF( tb );
}
-
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( "last_traceback", Py_None);
return;
}
@@ -2727,6 +2732,8 @@ int BPY_call_importloader( char *name )
* Description: This function executes the python script passed by text.
* The Python dictionary containing global variables needs to
* be passed in globaldict.
+* NOTE: Make sure BPY_Err_Handle() runs if this returns NULL
+* otherwise pointers can be left in sys.last_traceback that become invalid.
*****************************************************************************/
static PyObject *RunPython( Text * text, PyObject * globaldict )
{
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index 4cb9bc8fe53..1bbb93e0acc 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -262,6 +262,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
printf("Python compile error from controller \"%s\": \n", GetName().Ptr());
//PyRun_SimpleString(m_scriptText.Ptr());
PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( "last_traceback", Py_None);
+
return;
}
m_bModified=false;
@@ -298,6 +305,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
// something is wrong, tell the user what went wrong
printf("Python script error from controller \"%s\": \n", GetName().Ptr());
PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( "last_traceback", Py_None);
+
//PyRun_SimpleString(m_scriptText.Ptr());
}