~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/python/intern/bpy_util.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include <Python.h>
31
31
 
 
32
#include "BLI_utildefines.h"
 
33
#include "BLI_dynstr.h"
 
34
 
32
35
#include "bpy_util.h"
33
 
#include "BLI_dynstr.h"
 
36
 
34
37
#include "MEM_guardedalloc.h"
 
38
 
35
39
#include "BKE_report.h"
36
40
#include "BKE_context.h"
37
41
 
 
42
#include "BLF_translation.h"
 
43
 
38
44
#include "../generic/py_capi_utils.h"
39
45
 
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; }
43
49
 
57
63
        return cstring;
58
64
}
59
65
 
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)
61
67
{
62
68
        char *report_str;
63
69
 
64
70
        report_str = BKE_reports_string(reports, RPT_ERROR);
65
71
 
66
 
        if (clear) {
 
72
        if (clear == true) {
67
73
                BKE_reports_clear(reports);
68
74
        }
69
75
 
79
85
short BPy_errors_to_report(ReportList *reports)
80
86
{
81
87
        PyObject *pystring;
82
 
        PyObject *pystring_format = NULL; // workaround, see below
 
88
        PyObject *pystring_format = NULL;  /* workaround, see below */
83
89
        char *cstring;
84
90
 
85
91
        const char *filename;
98
104
        pystring = PyC_ExceptionBuffer();
99
105
        
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");
102
108
                return 0;
103
109
        }
104
110
        
108
114
        
109
115
        cstring = _PyUnicode_AsString(pystring);
110
116
 
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);
113
119
#else
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);
117
123
#endif
118
 
        
119
 
        fprintf(stderr, "%s\nlocation:%s:%d\n", cstring, filename, lineno); // not exactly needed. just for testing
120
 
        
 
124
 
 
125
        /* not exactly needed. just for testing */
 
126
        fprintf(stderr, TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno);
 
127
 
121
128
        Py_DECREF(pystring);
122
 
        Py_DECREF(pystring_format); // workaround
 
129
        Py_DECREF(pystring_format);  /* workaround */
123
130
        return 1;
124
131
}