diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-25 07:36:10 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-25 07:36:10 +0300 |
commit | a21f46b6d43c3743b96515e9733faf78d70c36ed (patch) | |
tree | 2378b9cc22ce2337c3fc2a966c2fafc16d64d344 /source/blender/python | |
parent | 16e736b7db3ef3597e22f55e7b26416ee562a418 (diff) |
new function RNA_warning(), replaces printf with function which may be called via python.
Now this gives the line number of the scripts thats running, eg:
uiItemFullO: unknown operator 'some.operator'
/c/bin/2.56/scripts/startup/bl_ui/space_view3d_toolbar.py:73
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 9 | ||||
-rw-r--r-- | source/blender/python/generic/py_capi_utils.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index fd44e09003e..7182d5f75d0 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -30,6 +30,8 @@ #include "py_capi_utils.h" +#define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL) + /* for debugging */ void PyC_ObSpit(const char *name, PyObject *var) { fprintf(stderr, "<%s> : ", name); @@ -51,9 +53,16 @@ void PyC_ObSpit(const char *name, PyObject *var) { } void PyC_LineSpit(void) { + const char *filename; int lineno; + /* Note, allow calling from outside python (RNA) */ + if(!PYC_INTERPRETER_ACTIVE) { + fprintf(stderr, "python line lookup failed, interpreter inactive\n"); + return; + } + PyErr_Clear(); PyC_FileAndNum(&filename, &lineno); diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index c78e78b5a0b..0b821759bec 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -47,4 +47,5 @@ void PyC_RunQuicky(const char *filepath, int n, ...); void PyC_MainModule_Backup(PyObject **main_mod); void PyC_MainModule_Restore(PyObject *main_mod); + #endif // PY_CAPI_UTILS_H |