30
30
#include <Python.h>
32
#include "BLI_utildefines.h"
33
#include "BLI_dynstr.h"
32
35
#include "bpy_util.h"
33
#include "BLI_dynstr.h"
34
37
#include "MEM_guardedalloc.h"
35
39
#include "BKE_report.h"
36
40
#include "BKE_context.h"
42
#include "BLF_translation.h"
38
44
#include "../generic/py_capi_utils.h"
40
static bContext* __py_context = NULL;
46
static bContext *__py_context = NULL;
41
47
bContext *BPy_GetContext(void) { return __py_context; }
42
48
void BPy_SetContext(bContext *C) { __py_context = C; }
60
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const short clear)
66
short BPy_reports_to_error(ReportList *reports, PyObject *exception, const bool clear)
64
70
report_str = BKE_reports_string(reports, RPT_ERROR);
67
73
BKE_reports_clear(reports);
98
104
pystring = PyC_ExceptionBuffer();
100
106
if (pystring == NULL) {
101
BKE_report(reports, RPT_ERROR, "unknown py-exception, couldn't convert");
107
BKE_report(reports, RPT_ERROR, "Unknown py-exception, could not convert");
109
115
cstring = _PyUnicode_AsString(pystring);
111
#if 0 // ARG!. workaround for a bug in blenders use of vsnprintf
112
BKE_reportf(reports, RPT_ERROR, "%s\nlocation:%s:%d\n", cstring, filename, lineno);
117
#if 0 /* ARG!. workaround for a bug in blenders use of vsnprintf */
118
BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", cstring, filename, lineno);
114
pystring_format = PyUnicode_FromFormat("%s\nlocation:%s:%d\n", cstring, filename, lineno);
120
pystring_format = PyUnicode_FromFormat(TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno);
115
121
cstring = _PyUnicode_AsString(pystring_format);
116
122
BKE_report(reports, RPT_ERROR, cstring);
119
fprintf(stderr, "%s\nlocation:%s:%d\n", cstring, filename, lineno); // not exactly needed. just for testing
125
/* not exactly needed. just for testing */
126
fprintf(stderr, TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno);
121
128
Py_DECREF(pystring);
122
Py_DECREF(pystring_format); // workaround
129
Py_DECREF(pystring_format); /* workaround */