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>2020-08-06 08:48:42 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-08-06 08:48:42 +0300
commit14dc1aecf0e3dfb4abf8dc1ebfa4494df99b9e01 (patch)
tree62cac48b4a81d8dc14ceabd17c4c0ee99d89b69b /source/blender/python
parentc86fed79d5fda0b8ac0c560f71fd6001e6bf7ca8 (diff)
parente9c4325515aed9cb3a35183d4093cda2b6bffd9f (diff)
Merge branch 'blender-v2.90-release' into master
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/BPY_extern.h1
-rw-r--r--source/blender/python/generic/py_capi_utils.c14
-rw-r--r--source/blender/python/generic/py_capi_utils.h1
-rw-r--r--source/blender/python/intern/bpy_interface.c6
4 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 049b919b4a4..74d46f6c56f 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -55,6 +55,7 @@ void BPY_python_start(int argc, const char **argv);
void BPY_python_end(void);
void BPY_python_reset(struct bContext *C);
void BPY_python_use_system_env(void);
+void BPY_python_backtrace(FILE *file);
/* global interpreter lock */
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index a5b0e244fde..413e27589fd 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -383,6 +383,20 @@ void PyC_StackSpit(void)
}
}
+void PyC_StackPrint(FILE *fp)
+{
+ PyThreadState *tstate = PyGILState_GetThisThreadState();
+ if (tstate != NULL && tstate->frame != NULL) {
+ PyFrameObject *frame = tstate->frame;
+ do {
+ const int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
+ const char *filename = _PyUnicode_AsString(frame->f_code->co_filename);
+ const char *funcname = _PyUnicode_AsString(frame->f_code->co_name);
+ fprintf(fp, " File \"%s\", line %d in %s\n", filename, line, funcname);
+ } while ((frame = frame->f_back));
+ }
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index e8b2e8ff502..7950ee2c968 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -28,6 +28,7 @@ void PyC_ObSpit(const char *name, PyObject *var);
void PyC_ObSpitStr(char *result, size_t result_len, PyObject *var);
void PyC_LineSpit(void);
void PyC_StackSpit(void);
+void PyC_StackPrint(FILE *fp);
PyObject *PyC_ExceptionBuffer(void);
PyObject *PyC_ExceptionBuffer_Simple(void);
PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...);
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 585119a0eae..3dcd1d944a5 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -438,6 +438,12 @@ static void python_script_error_jump_text(struct Text *text)
}
}
+void BPY_python_backtrace(FILE *fp)
+{
+ fputs("\n# Python backtrace\n", fp);
+ PyC_StackPrint(fp);
+}
+
/* super annoying, undo _PyModule_Clear(), bug [#23871] */
#define PYMODULE_CLEAR_WORKAROUND