~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to source/blender/python/intern/bpy_traceback.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:
39
39
        return PyBytes_AS_STRING((*coerce = PyUnicode_EncodeFSDefault(tb->tb_frame->f_code->co_filename)));
40
40
}
41
41
 
42
 
/* copied from pythonrun.c, 3.2.0 */
 
42
/* copied from pythonrun.c, 3.3.0 */
43
43
static int
44
44
parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
45
45
                   int *lineno, int *offset, const char **text)
46
46
{
47
47
        long hold;
48
48
        PyObject *v;
 
49
        _Py_IDENTIFIER(msg);
 
50
        _Py_IDENTIFIER(filename);
 
51
        _Py_IDENTIFIER(lineno);
 
52
        _Py_IDENTIFIER(offset);
 
53
        _Py_IDENTIFIER(text);
49
54
 
50
 
        /* old style errors */
51
 
        if (PyTuple_Check(err))
52
 
                return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
53
 
                                        lineno, offset, text);
 
55
        *message = NULL;
54
56
 
55
57
        /* new style errors.  `err' is an instance */
56
 
 
57
 
        if (!(v = PyObject_GetAttrString(err, "msg")))
58
 
                goto finally;
59
 
        *message = v;
60
 
 
61
 
        if (!(v = PyObject_GetAttrString(err, "filename")))
62
 
                goto finally;
63
 
        if (v == Py_None)
 
58
        *message = _PyObject_GetAttrId(err, &PyId_msg);
 
59
        if (!*message)
 
60
                goto finally;
 
61
 
 
62
        v = _PyObject_GetAttrId(err, &PyId_filename);
 
63
        if (!v)
 
64
                goto finally;
 
65
        if (v == Py_None) {
 
66
                Py_DECREF(v);
64
67
                *filename = NULL;
65
 
        else if (!(*filename = _PyUnicode_AsString(v)))
66
 
                goto finally;
 
68
        }
 
69
        else {
 
70
                *filename = _PyUnicode_AsString(v);
 
71
                Py_DECREF(v);
 
72
                if (!*filename)
 
73
                        goto finally;
 
74
        }
67
75
 
68
 
        Py_DECREF(v);
69
 
        if (!(v = PyObject_GetAttrString(err, "lineno")))
 
76
        v = _PyObject_GetAttrId(err, &PyId_lineno);
 
77
        if (!v)
70
78
                goto finally;
71
79
        hold = PyLong_AsLong(v);
72
80
        Py_DECREF(v);
73
 
        v = NULL;
74
81
        if (hold < 0 && PyErr_Occurred())
75
82
                goto finally;
76
83
        *lineno = (int)hold;
77
84
 
78
 
        if (!(v = PyObject_GetAttrString(err, "offset")))
 
85
        v = _PyObject_GetAttrId(err, &PyId_offset);
 
86
        if (!v)
79
87
                goto finally;
80
88
        if (v == Py_None) {
81
89
                *offset = -1;
82
90
                Py_DECREF(v);
83
 
                v = NULL;
84
 
        }
85
 
        else {
 
91
        } else {
86
92
                hold = PyLong_AsLong(v);
87
93
                Py_DECREF(v);
88
 
                v = NULL;
89
94
                if (hold < 0 && PyErr_Occurred())
90
95
                        goto finally;
91
96
                *offset = (int)hold;
92
97
        }
93
98
 
94
 
        if (!(v = PyObject_GetAttrString(err, "text")))
 
99
        v = _PyObject_GetAttrId(err, &PyId_text);
 
100
        if (!v)
95
101
                goto finally;
96
 
        if (v == Py_None)
 
102
        if (v == Py_None) {
 
103
                Py_DECREF(v);
97
104
                *text = NULL;
98
 
        else if (!PyUnicode_Check(v) ||
99
 
                 !(*text = _PyUnicode_AsString(v)))
100
 
                goto finally;
101
 
        Py_DECREF(v);
 
105
        }
 
106
        else {
 
107
                *text = _PyUnicode_AsString(v);
 
108
                Py_DECREF(v);
 
109
                if (!*text)
 
110
                        goto finally;
 
111
        }
102
112
        return 1;
103
113
 
104
114
finally:
105
 
        Py_XDECREF(v);
 
115
        Py_XDECREF(*message);
106
116
        return 0;
107
117
}
108
118
/* end copied function! */