blob: 60e15b6dba7013459ee91610161a57987a6e7c9c [file] [log] [blame]
Damiend99b0522013-12-21 18:17:45 +00001#include <string.h>
Damien George6c73ca12014-01-08 18:11:23 +00002#include <stdarg.h>
Damiend99b0522013-12-21 18:17:45 +00003#include <assert.h>
4
5#include "nlr.h"
6#include "misc.h"
7#include "mpconfig.h"
Damien George55baff42014-01-21 21:40:13 +00008#include "qstr.h"
Damiend99b0522013-12-21 18:17:45 +00009#include "obj.h"
Paul Sokolovskyddf21782014-01-12 23:30:20 +020010#include "objtuple.h"
Paul Sokolovsky962b1cd2014-03-23 21:48:29 +020011#include "runtime.h"
12#include "runtime0.h"
Damiend99b0522013-12-21 18:17:45 +000013
Damien George07ddab52014-03-29 13:15:08 +000014typedef struct _mp_obj_exception_t {
Damiend99b0522013-12-21 18:17:45 +000015 mp_obj_base_t base;
Damien George136b1492014-01-19 12:38:49 +000016 mp_obj_t traceback; // a list object, holding (file,line,block) as numbers (not Python objects); a hack for now
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030017 mp_obj_tuple_t *args;
Damiend99b0522013-12-21 18:17:45 +000018} mp_obj_exception_t;
19
Damien George6902eed2014-04-04 10:52:59 +000020// Instance of MemoryError exception - needed by mp_malloc_fail
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030021const mp_obj_exception_t mp_const_MemoryError_obj = {{&mp_type_MemoryError}, MP_OBJ_NULL, mp_const_empty_tuple};
Damien George6902eed2014-04-04 10:52:59 +000022
Damien Georgef0954e32014-04-10 14:38:25 +010023// Local non-heap memory for allocating an exception when we run out of RAM
24STATIC mp_obj_exception_t mp_emergency_exception_obj;
25
Paul Sokolovskyc4d589e2014-03-28 02:37:28 +020026// Instance of GeneratorExit exception - needed by generator.close()
27// This would belong to objgenerator.c, but to keep mp_obj_exception_t
28// definition module-private so far, have it here.
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030029const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, MP_OBJ_NULL, mp_const_empty_tuple};
Paul Sokolovskyc4d589e2014-03-28 02:37:28 +020030
Damien Georgec5966122014-02-15 16:10:44 +000031STATIC void mp_obj_exception_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
Damiend99b0522013-12-21 18:17:45 +000032 mp_obj_exception_t *o = o_in;
Paul Sokolovskyd8351ca2014-05-02 01:51:25 +030033 mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS;
34 bool is_subclass = kind & PRINT_EXC_SUBCLASS;
35 if (!is_subclass && (k == PRINT_REPR || k == PRINT_EXC)) {
Paul Sokolovskya96d3d02014-03-31 01:10:10 +030036 print(env, "%s", qstr_str(o->base.type->name));
Damiend99b0522013-12-21 18:17:45 +000037 }
Paul Sokolovskyd8351ca2014-05-02 01:51:25 +030038
39 if (k == PRINT_EXC) {
40 print(env, ": ");
41 }
42
43 if (k == PRINT_STR || k == PRINT_EXC) {
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030044 if (o->args == NULL || o->args->len == 0) {
Paul Sokolovskya96d3d02014-03-31 01:10:10 +030045 print(env, "");
46 return;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030047 } else if (o->args->len == 1) {
48 mp_obj_print_helper(print, env, o->args->items[0], PRINT_STR);
Paul Sokolovskya96d3d02014-03-31 01:10:10 +030049 return;
50 }
51 }
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030052 tuple_print(print, env, o->args, kind);
Damiend99b0522013-12-21 18:17:45 +000053}
54
Paul Sokolovskyd8351ca2014-05-02 01:51:25 +030055mp_obj_t mp_obj_exception_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
Damien Georgec5966122014-02-15 16:10:44 +000056 mp_obj_type_t *type = type_in;
Damien George20006db2014-01-18 14:10:48 +000057
58 if (n_kw != 0) {
Damien Georgeea13f402014-04-05 18:32:08 +010059 nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "%s does not take keyword arguments", mp_obj_get_type_str(type_in)));
Damien George20006db2014-01-18 14:10:48 +000060 }
61
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030062 mp_obj_exception_t *o = m_new_obj_var_maybe(mp_obj_exception_t, mp_obj_t, 0);
Damien Georgef0954e32014-04-10 14:38:25 +010063 if (o == NULL) {
64 // Couldn't allocate heap memory; use local data instead.
65 o = &mp_emergency_exception_obj;
66 // We can't store any args.
67 n_args = 0;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030068 o->args = mp_const_empty_tuple;
69 } else {
70 o->args = mp_obj_new_tuple(n_args, args);
Damien Georgef0954e32014-04-10 14:38:25 +010071 }
Damien Georgec5966122014-02-15 16:10:44 +000072 o->base.type = type;
Paul Sokolovsky60a0d3f2014-02-14 21:01:12 +020073 o->traceback = MP_OBJ_NULL;
Paul Sokolovskyddf21782014-01-12 23:30:20 +020074 return o;
75}
76
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020077// Get exception "value" - that is, first argument, or None
78mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) {
79 mp_obj_exception_t *self = self_in;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030080 if (self->args->len == 0) {
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020081 return mp_const_none;
82 } else {
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030083 return self->args->items[0];
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020084 }
85}
86
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +020087STATIC void exception_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
88 mp_obj_exception_t *self = self_in;
89 if (attr == MP_QSTR_args) {
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030090 dest[0] = self->args;
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +020091 } else if (self->base.type == &mp_type_StopIteration && attr == MP_QSTR_value) {
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020092 dest[0] = mp_obj_exception_get_value(self);
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +020093 }
94}
95
Damien Georgec5966122014-02-15 16:10:44 +000096const mp_obj_type_t mp_type_BaseException = {
97 { &mp_type_type },
98 .name = MP_QSTR_BaseException,
99 .print = mp_obj_exception_print,
100 .make_new = mp_obj_exception_make_new,
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +0200101 .load_attr = exception_load_attr,
Damiend99b0522013-12-21 18:17:45 +0000102};
103
Damien George22a08652014-02-15 21:05:25 +0000104#define MP_DEFINE_EXCEPTION_BASE(base_name) \
Damien George07ddab52014-03-29 13:15:08 +0000105STATIC const mp_obj_tuple_t mp_type_ ## base_name ## _base_tuple = {{&mp_type_tuple}, 1, {(mp_obj_t)&mp_type_ ## base_name}};\
Damien George22a08652014-02-15 21:05:25 +0000106
107#define MP_DEFINE_EXCEPTION(exc_name, base_name) \
Damien Georgec5966122014-02-15 16:10:44 +0000108const mp_obj_type_t mp_type_ ## exc_name = { \
109 { &mp_type_type }, \
110 .name = MP_QSTR_ ## exc_name, \
111 .print = mp_obj_exception_print, \
112 .make_new = mp_obj_exception_make_new, \
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +0200113 .load_attr = exception_load_attr, \
Damien George22a08652014-02-15 21:05:25 +0000114 .bases_tuple = (mp_obj_t)&mp_type_ ## base_name ## _base_tuple, \
Damien Georgec5966122014-02-15 16:10:44 +0000115};
116
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000117// List of all exceptions, arranged as in the table at:
118// http://docs.python.org/3.3/library/exceptions.html
Damien George22a08652014-02-15 21:05:25 +0000119MP_DEFINE_EXCEPTION_BASE(BaseException)
Damien Georgeffb5cfc2014-03-25 14:29:40 +0000120//MP_DEFINE_EXCEPTION(SystemExit, BaseException)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000121//MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
122MP_DEFINE_EXCEPTION(GeneratorExit, BaseException)
123MP_DEFINE_EXCEPTION(Exception, BaseException)
124 MP_DEFINE_EXCEPTION_BASE(Exception)
125 MP_DEFINE_EXCEPTION(StopIteration, Exception)
126 MP_DEFINE_EXCEPTION(ArithmeticError, Exception)
127 MP_DEFINE_EXCEPTION_BASE(ArithmeticError)
Damien Georgec63f9842014-03-27 23:49:06 +0000128 //MP_DEFINE_EXCEPTION(FloatingPointError, ArithmeticError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000129 MP_DEFINE_EXCEPTION(OverflowError, ArithmeticError)
130 MP_DEFINE_EXCEPTION(ZeroDivisionError, ArithmeticError)
131 MP_DEFINE_EXCEPTION(AssertionError, Exception)
132 MP_DEFINE_EXCEPTION(AttributeError, Exception)
Damien Georgec63f9842014-03-27 23:49:06 +0000133 //MP_DEFINE_EXCEPTION(BufferError, Exception)
Damien Georgeffb5cfc2014-03-25 14:29:40 +0000134 //MP_DEFINE_EXCEPTION(EnvironmentError, Exception)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000135 MP_DEFINE_EXCEPTION(EOFError, Exception)
136 MP_DEFINE_EXCEPTION(ImportError, Exception)
137 MP_DEFINE_EXCEPTION(IOError, Exception)
138 MP_DEFINE_EXCEPTION(LookupError, Exception)
139 MP_DEFINE_EXCEPTION_BASE(LookupError)
140 MP_DEFINE_EXCEPTION(IndexError, LookupError)
141 MP_DEFINE_EXCEPTION(KeyError, LookupError)
142 MP_DEFINE_EXCEPTION(MemoryError, Exception)
143 MP_DEFINE_EXCEPTION(NameError, Exception)
144 MP_DEFINE_EXCEPTION_BASE(NameError)
Damien Georgec63f9842014-03-27 23:49:06 +0000145 //MP_DEFINE_EXCEPTION(UnboundLocalError, NameError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000146 MP_DEFINE_EXCEPTION(OSError, Exception)
Damien Georgec9109722014-03-22 23:40:02 +0000147 MP_DEFINE_EXCEPTION_BASE(OSError)
Damien Georgec63f9842014-03-27 23:49:06 +0000148 /*
149 MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000150 MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
151 MP_DEFINE_EXCEPTION(ConnectionError, OSError)
152 MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError)
153 MP_DEFINE_EXCEPTION(ConnectionAbortedError, ConnectionError)
154 MP_DEFINE_EXCEPTION(ConnectionRefusedError, ConnectionError)
155 MP_DEFINE_EXCEPTION(ConnectionResetError, ConnectionError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000156 MP_DEFINE_EXCEPTION(InterruptedError, OSError)
157 MP_DEFINE_EXCEPTION(IsADirectoryError, OSError)
158 MP_DEFINE_EXCEPTION(NotADirectoryError, OSError)
159 MP_DEFINE_EXCEPTION(PermissionError, OSError)
160 MP_DEFINE_EXCEPTION(ProcessLookupError, OSError)
Damien Georgec63f9842014-03-27 23:49:06 +0000161 MP_DEFINE_EXCEPTION(TimeoutError, OSError)
Damien Georgec9109722014-03-22 23:40:02 +0000162 MP_DEFINE_EXCEPTION(FileExistsError, OSError)
163 MP_DEFINE_EXCEPTION(FileNotFoundError, OSError)
Damien Georgec63f9842014-03-27 23:49:06 +0000164 MP_DEFINE_EXCEPTION(ReferenceError, Exception)
165 */
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000166 MP_DEFINE_EXCEPTION(RuntimeError, Exception)
167 MP_DEFINE_EXCEPTION_BASE(RuntimeError)
168 MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError)
169 MP_DEFINE_EXCEPTION(SyntaxError, Exception)
170 MP_DEFINE_EXCEPTION_BASE(SyntaxError)
171 MP_DEFINE_EXCEPTION(IndentationError, SyntaxError)
Damien Georgec63f9842014-03-27 23:49:06 +0000172 /*
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000173 MP_DEFINE_EXCEPTION_BASE(IndentationError)
Damien Georgec63f9842014-03-27 23:49:06 +0000174 MP_DEFINE_EXCEPTION(TabError, IndentationError)
175 */
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000176 MP_DEFINE_EXCEPTION(SystemError, Exception)
177 MP_DEFINE_EXCEPTION(TypeError, Exception)
178 MP_DEFINE_EXCEPTION(ValueError, Exception)
179 //TODO: Implement UnicodeErrors which take arguments
Damien Georgec9109722014-03-22 23:40:02 +0000180 /*
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000181 MP_DEFINE_EXCEPTION(Warning, Exception)
182 MP_DEFINE_EXCEPTION_BASE(Warning)
183 MP_DEFINE_EXCEPTION(DeprecationWarning, Warning)
184 MP_DEFINE_EXCEPTION(PendingDeprecationWarning, Warning)
185 MP_DEFINE_EXCEPTION(RuntimeWarning, Warning)
186 MP_DEFINE_EXCEPTION(SyntaxWarning, Warning)
187 MP_DEFINE_EXCEPTION(UserWarning, Warning)
188 MP_DEFINE_EXCEPTION(FutureWarning, Warning)
189 MP_DEFINE_EXCEPTION(ImportWarning, Warning)
190 MP_DEFINE_EXCEPTION(UnicodeWarning, Warning)
191 MP_DEFINE_EXCEPTION(BytesWarning, Warning)
192 MP_DEFINE_EXCEPTION(ResourceWarning, Warning)
Damien Georgec9109722014-03-22 23:40:02 +0000193 */
Damien Georgec5966122014-02-15 16:10:44 +0000194
195mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) {
Paul Sokolovskya96d3d02014-03-31 01:10:10 +0300196 return mp_obj_new_exception_args(exc_type, 0, NULL);
Damiend99b0522013-12-21 18:17:45 +0000197}
198
Paul Sokolovskydec31bb2014-04-22 00:01:13 +0300199// "Optimized" version for common(?) case of having 1 exception arg
200mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) {
201 return mp_obj_new_exception_args(exc_type, 1, &arg);
202}
203
Paul Sokolovsky962b1cd2014-03-23 21:48:29 +0200204mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, uint n_args, const mp_obj_t *args) {
205 assert(exc_type->make_new == mp_obj_exception_make_new);
206 return exc_type->make_new((mp_obj_t)exc_type, n_args, 0, args);
207}
208
Damien Georgec5966122014-02-15 16:10:44 +0000209mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg) {
210 return mp_obj_new_exception_msg_varg(exc_type, msg);
Damiend99b0522013-12-21 18:17:45 +0000211}
212
Damien Georgec5966122014-02-15 16:10:44 +0000213mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...) {
214 // check that the given type is an exception type
215 assert(exc_type->make_new == mp_obj_exception_make_new);
216
Damien George6c73ca12014-01-08 18:11:23 +0000217 // make exception object
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300218 mp_obj_exception_t *o = m_new_obj_var_maybe(mp_obj_exception_t, mp_obj_t, 0);
Damien Georgef0954e32014-04-10 14:38:25 +0100219 if (o == NULL) {
220 // Couldn't allocate heap memory; use local data instead.
221 // Unfortunately, we won't be able to format the string...
222 o = &mp_emergency_exception_obj;
223 o->base.type = exc_type;
224 o->traceback = MP_OBJ_NULL;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300225 o->args = mp_const_empty_tuple;
Paul Sokolovskyddf21782014-01-12 23:30:20 +0200226 } else {
Damien Georgef0954e32014-04-10 14:38:25 +0100227 o->base.type = exc_type;
228 o->traceback = MP_OBJ_NULL;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300229 o->args = mp_obj_new_tuple(1, NULL);
Damien Georgef0954e32014-04-10 14:38:25 +0100230
231 if (fmt == NULL) {
232 // no message
233 assert(0);
234 } else {
235 // render exception message and store as .args[0]
236 // TODO: optimize bufferbloat
237 vstr_t *vstr = vstr_new();
238 va_list ap;
239 va_start(ap, fmt);
240 vstr_vprintf(vstr, fmt, ap);
241 va_end(ap);
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300242 o->args->items[0] = mp_obj_new_str((byte*)vstr->buf, vstr->len, false);
Damien Georgef0954e32014-04-10 14:38:25 +0100243 vstr_free(vstr);
244 }
Damien George6c73ca12014-01-08 18:11:23 +0000245 }
Damien George6c73ca12014-01-08 18:11:23 +0000246
247 return o;
248}
249
Damien Georgec5966122014-02-15 16:10:44 +0000250// return true if the given object is an exception type
Damien Georgec5966122014-02-15 16:10:44 +0000251bool mp_obj_is_exception_type(mp_obj_t self_in) {
252 if (MP_OBJ_IS_TYPE(self_in, &mp_type_type)) {
Damien George9e6e9352014-03-26 18:37:06 +0000253 // optimisation when self_in is a builtin exception
Damien Georgec5966122014-02-15 16:10:44 +0000254 mp_obj_type_t *self = self_in;
Damien George9e6e9352014-03-26 18:37:06 +0000255 if (self->make_new == mp_obj_exception_make_new) {
256 return true;
257 }
Damien Georgec5966122014-02-15 16:10:44 +0000258 }
Damien George9e6e9352014-03-26 18:37:06 +0000259 return mp_obj_is_subclass_fast(self_in, &mp_type_BaseException);
Damien Georgec5966122014-02-15 16:10:44 +0000260}
261
262// return true if the given object is an instance of an exception type
Damien Georgec5966122014-02-15 16:10:44 +0000263bool mp_obj_is_exception_instance(mp_obj_t self_in) {
Damien George9e6e9352014-03-26 18:37:06 +0000264 return mp_obj_is_exception_type(mp_obj_get_type(self_in));
Damien Georgec5966122014-02-15 16:10:44 +0000265}
266
Paul Sokolovsky962b1cd2014-03-23 21:48:29 +0200267// return true if exception (type or instance) is a subclass of given
268// exception type.
269bool mp_obj_exception_match(mp_obj_t exc, const mp_obj_type_t *exc_type) {
270 // TODO: move implementation from RT_BINARY_OP_EXCEPTION_MATCH here.
Damien Georged17926d2014-03-30 13:35:08 +0100271 return mp_binary_op(MP_BINARY_OP_EXCEPTION_MATCH, exc, (mp_obj_t)exc_type) == mp_const_true;
Paul Sokolovsky962b1cd2014-03-23 21:48:29 +0200272}
273
Damien Georgec5966122014-02-15 16:10:44 +0000274void mp_obj_exception_clear_traceback(mp_obj_t self_in) {
275 // make sure self_in is an exception instance
Damien George9e6e9352014-03-26 18:37:06 +0000276 // TODO add traceback information to user-defined exceptions (need proper builtin subclassing for that)
277 if (mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new) {
278 mp_obj_exception_t *self = self_in;
Damien Georgec5966122014-02-15 16:10:44 +0000279
Damien George9e6e9352014-03-26 18:37:06 +0000280 // just set the traceback to the null object
281 // we don't want to call any memory management functions here
282 self->traceback = MP_OBJ_NULL;
283 }
Damienb86e3f92013-12-29 17:17:43 +0000284}
Damien George08335002014-01-18 23:24:36 +0000285
Damien George136b1492014-01-19 12:38:49 +0000286void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, machine_uint_t line, qstr block) {
Damien Georgec5966122014-02-15 16:10:44 +0000287 // make sure self_in is an exception instance
Damien George9e6e9352014-03-26 18:37:06 +0000288 // TODO add traceback information to user-defined exceptions (need proper builtin subclassing for that)
Damien Georgef0954e32014-04-10 14:38:25 +0100289 if (mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new && self_in != &mp_emergency_exception_obj) {
Damien George9e6e9352014-03-26 18:37:06 +0000290 mp_obj_exception_t *self = self_in;
Damien Georgec5966122014-02-15 16:10:44 +0000291
Damien George9e6e9352014-03-26 18:37:06 +0000292 // for traceback, we are just using the list object for convenience, it's not really a list of Python objects
293 if (self->traceback == MP_OBJ_NULL) {
294 self->traceback = mp_obj_new_list(0, NULL);
295 }
296 mp_obj_list_append(self->traceback, (mp_obj_t)(machine_uint_t)file);
297 mp_obj_list_append(self->traceback, (mp_obj_t)(machine_uint_t)line);
298 mp_obj_list_append(self->traceback, (mp_obj_t)(machine_uint_t)block);
Damien George08335002014-01-18 23:24:36 +0000299 }
Damien George08335002014-01-18 23:24:36 +0000300}
301
Damien George136b1492014-01-19 12:38:49 +0000302void mp_obj_exception_get_traceback(mp_obj_t self_in, machine_uint_t *n, machine_uint_t **values) {
Damien Georgec5966122014-02-15 16:10:44 +0000303 // make sure self_in is an exception instance
304 assert(mp_obj_get_type(self_in)->make_new == mp_obj_exception_make_new);
Damien George08335002014-01-18 23:24:36 +0000305 mp_obj_exception_t *self = self_in;
Damien Georgec5966122014-02-15 16:10:44 +0000306
Damien George136b1492014-01-19 12:38:49 +0000307 if (self->traceback == MP_OBJ_NULL) {
308 *n = 0;
309 *values = NULL;
310 } else {
311 uint n2;
312 mp_obj_list_get(self->traceback, &n2, (mp_obj_t**)values);
313 *n = n2;
314 }
Damien George08335002014-01-18 23:24:36 +0000315}