blob: 7fd00c11c7a971c4b8db2aebd4cdaece71bddbe3 [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 Sokolovsky91e556a2014-05-02 02:27:00 +030011#include "objtype.h"
Paul Sokolovsky962b1cd2014-03-23 21:48:29 +020012#include "runtime.h"
13#include "runtime0.h"
Damiend99b0522013-12-21 18:17:45 +000014
Damien George07ddab52014-03-29 13:15:08 +000015typedef struct _mp_obj_exception_t {
Damiend99b0522013-12-21 18:17:45 +000016 mp_obj_base_t base;
Damien George136b1492014-01-19 12:38:49 +000017 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 +030018 mp_obj_tuple_t *args;
Damiend99b0522013-12-21 18:17:45 +000019} mp_obj_exception_t;
20
Damien George6902eed2014-04-04 10:52:59 +000021// Instance of MemoryError exception - needed by mp_malloc_fail
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030022const 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 +000023
Damien Georgef0954e32014-04-10 14:38:25 +010024// Local non-heap memory for allocating an exception when we run out of RAM
25STATIC mp_obj_exception_t mp_emergency_exception_obj;
26
Paul Sokolovskyc4d589e2014-03-28 02:37:28 +020027// Instance of GeneratorExit exception - needed by generator.close()
28// This would belong to objgenerator.c, but to keep mp_obj_exception_t
29// definition module-private so far, have it here.
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030030const 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 +020031
Damien Georgec5966122014-02-15 16:10:44 +000032STATIC 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 +000033 mp_obj_exception_t *o = o_in;
Paul Sokolovskyd8351ca2014-05-02 01:51:25 +030034 mp_print_kind_t k = kind & ~PRINT_EXC_SUBCLASS;
35 bool is_subclass = kind & PRINT_EXC_SUBCLASS;
36 if (!is_subclass && (k == PRINT_REPR || k == PRINT_EXC)) {
Paul Sokolovskya96d3d02014-03-31 01:10:10 +030037 print(env, "%s", qstr_str(o->base.type->name));
Damiend99b0522013-12-21 18:17:45 +000038 }
Paul Sokolovskyd8351ca2014-05-02 01:51:25 +030039
40 if (k == PRINT_EXC) {
41 print(env, ": ");
42 }
43
44 if (k == PRINT_STR || k == PRINT_EXC) {
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030045 if (o->args == NULL || o->args->len == 0) {
Paul Sokolovskya96d3d02014-03-31 01:10:10 +030046 print(env, "");
47 return;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030048 } else if (o->args->len == 1) {
49 mp_obj_print_helper(print, env, o->args->items[0], PRINT_STR);
Paul Sokolovskya96d3d02014-03-31 01:10:10 +030050 return;
51 }
52 }
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030053 tuple_print(print, env, o->args, kind);
Damiend99b0522013-12-21 18:17:45 +000054}
55
Paul Sokolovskyd8351ca2014-05-02 01:51:25 +030056mp_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 +000057 mp_obj_type_t *type = type_in;
Damien George20006db2014-01-18 14:10:48 +000058
59 if (n_kw != 0) {
Damien Georgeea13f402014-04-05 18:32:08 +010060 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 +000061 }
62
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030063 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 +010064 if (o == NULL) {
65 // Couldn't allocate heap memory; use local data instead.
66 o = &mp_emergency_exception_obj;
67 // We can't store any args.
68 n_args = 0;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030069 o->args = mp_const_empty_tuple;
70 } else {
71 o->args = mp_obj_new_tuple(n_args, args);
Damien Georgef0954e32014-04-10 14:38:25 +010072 }
Damien Georgec5966122014-02-15 16:10:44 +000073 o->base.type = type;
Paul Sokolovsky60a0d3f2014-02-14 21:01:12 +020074 o->traceback = MP_OBJ_NULL;
Paul Sokolovskyddf21782014-01-12 23:30:20 +020075 return o;
76}
77
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020078// Get exception "value" - that is, first argument, or None
79mp_obj_t mp_obj_exception_get_value(mp_obj_t self_in) {
80 mp_obj_exception_t *self = self_in;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030081 if (self->args->len == 0) {
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020082 return mp_const_none;
83 } else {
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030084 return self->args->items[0];
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020085 }
86}
87
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +020088STATIC void exception_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
89 mp_obj_exception_t *self = self_in;
90 if (attr == MP_QSTR_args) {
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +030091 dest[0] = self->args;
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +020092 } else if (self->base.type == &mp_type_StopIteration && attr == MP_QSTR_value) {
Paul Sokolovskyaf1ae302014-03-26 19:17:20 +020093 dest[0] = mp_obj_exception_get_value(self);
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +020094 }
95}
96
Damien Georgec5966122014-02-15 16:10:44 +000097const mp_obj_type_t mp_type_BaseException = {
98 { &mp_type_type },
99 .name = MP_QSTR_BaseException,
100 .print = mp_obj_exception_print,
101 .make_new = mp_obj_exception_make_new,
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +0200102 .load_attr = exception_load_attr,
Damiend99b0522013-12-21 18:17:45 +0000103};
104
Damien George22a08652014-02-15 21:05:25 +0000105#define MP_DEFINE_EXCEPTION_BASE(base_name) \
Damien George07ddab52014-03-29 13:15:08 +0000106STATIC 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 +0000107
108#define MP_DEFINE_EXCEPTION(exc_name, base_name) \
Damien Georgec5966122014-02-15 16:10:44 +0000109const mp_obj_type_t mp_type_ ## exc_name = { \
110 { &mp_type_type }, \
111 .name = MP_QSTR_ ## exc_name, \
112 .print = mp_obj_exception_print, \
113 .make_new = mp_obj_exception_make_new, \
Paul Sokolovsky9512e9e2014-03-25 01:29:09 +0200114 .load_attr = exception_load_attr, \
Damien George22a08652014-02-15 21:05:25 +0000115 .bases_tuple = (mp_obj_t)&mp_type_ ## base_name ## _base_tuple, \
Damien Georgec5966122014-02-15 16:10:44 +0000116};
117
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000118// List of all exceptions, arranged as in the table at:
119// http://docs.python.org/3.3/library/exceptions.html
Damien George22a08652014-02-15 21:05:25 +0000120MP_DEFINE_EXCEPTION_BASE(BaseException)
Damien Georgeffb5cfc2014-03-25 14:29:40 +0000121//MP_DEFINE_EXCEPTION(SystemExit, BaseException)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000122//MP_DEFINE_EXCEPTION(KeyboardInterrupt, BaseException)
123MP_DEFINE_EXCEPTION(GeneratorExit, BaseException)
124MP_DEFINE_EXCEPTION(Exception, BaseException)
125 MP_DEFINE_EXCEPTION_BASE(Exception)
126 MP_DEFINE_EXCEPTION(StopIteration, Exception)
127 MP_DEFINE_EXCEPTION(ArithmeticError, Exception)
128 MP_DEFINE_EXCEPTION_BASE(ArithmeticError)
Damien Georgec63f9842014-03-27 23:49:06 +0000129 //MP_DEFINE_EXCEPTION(FloatingPointError, ArithmeticError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000130 MP_DEFINE_EXCEPTION(OverflowError, ArithmeticError)
131 MP_DEFINE_EXCEPTION(ZeroDivisionError, ArithmeticError)
132 MP_DEFINE_EXCEPTION(AssertionError, Exception)
133 MP_DEFINE_EXCEPTION(AttributeError, Exception)
Damien Georgec63f9842014-03-27 23:49:06 +0000134 //MP_DEFINE_EXCEPTION(BufferError, Exception)
Damien Georgeffb5cfc2014-03-25 14:29:40 +0000135 //MP_DEFINE_EXCEPTION(EnvironmentError, Exception)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000136 MP_DEFINE_EXCEPTION(EOFError, Exception)
137 MP_DEFINE_EXCEPTION(ImportError, Exception)
138 MP_DEFINE_EXCEPTION(IOError, Exception)
139 MP_DEFINE_EXCEPTION(LookupError, Exception)
140 MP_DEFINE_EXCEPTION_BASE(LookupError)
141 MP_DEFINE_EXCEPTION(IndexError, LookupError)
142 MP_DEFINE_EXCEPTION(KeyError, LookupError)
143 MP_DEFINE_EXCEPTION(MemoryError, Exception)
144 MP_DEFINE_EXCEPTION(NameError, Exception)
145 MP_DEFINE_EXCEPTION_BASE(NameError)
Damien Georgec63f9842014-03-27 23:49:06 +0000146 //MP_DEFINE_EXCEPTION(UnboundLocalError, NameError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000147 MP_DEFINE_EXCEPTION(OSError, Exception)
Damien Georgec9109722014-03-22 23:40:02 +0000148 MP_DEFINE_EXCEPTION_BASE(OSError)
Damien Georgec63f9842014-03-27 23:49:06 +0000149 /*
150 MP_DEFINE_EXCEPTION(BlockingIOError, OSError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000151 MP_DEFINE_EXCEPTION(ChildProcessError, OSError)
152 MP_DEFINE_EXCEPTION(ConnectionError, OSError)
153 MP_DEFINE_EXCEPTION(BrokenPipeError, ConnectionError)
154 MP_DEFINE_EXCEPTION(ConnectionAbortedError, ConnectionError)
155 MP_DEFINE_EXCEPTION(ConnectionRefusedError, ConnectionError)
156 MP_DEFINE_EXCEPTION(ConnectionResetError, ConnectionError)
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000157 MP_DEFINE_EXCEPTION(InterruptedError, OSError)
158 MP_DEFINE_EXCEPTION(IsADirectoryError, OSError)
159 MP_DEFINE_EXCEPTION(NotADirectoryError, OSError)
160 MP_DEFINE_EXCEPTION(PermissionError, OSError)
161 MP_DEFINE_EXCEPTION(ProcessLookupError, OSError)
Damien Georgec63f9842014-03-27 23:49:06 +0000162 MP_DEFINE_EXCEPTION(TimeoutError, OSError)
Damien Georgec9109722014-03-22 23:40:02 +0000163 MP_DEFINE_EXCEPTION(FileExistsError, OSError)
164 MP_DEFINE_EXCEPTION(FileNotFoundError, OSError)
Damien Georgec63f9842014-03-27 23:49:06 +0000165 MP_DEFINE_EXCEPTION(ReferenceError, Exception)
166 */
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000167 MP_DEFINE_EXCEPTION(RuntimeError, Exception)
168 MP_DEFINE_EXCEPTION_BASE(RuntimeError)
169 MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError)
170 MP_DEFINE_EXCEPTION(SyntaxError, Exception)
171 MP_DEFINE_EXCEPTION_BASE(SyntaxError)
172 MP_DEFINE_EXCEPTION(IndentationError, SyntaxError)
Damien Georgec63f9842014-03-27 23:49:06 +0000173 /*
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000174 MP_DEFINE_EXCEPTION_BASE(IndentationError)
Damien Georgec63f9842014-03-27 23:49:06 +0000175 MP_DEFINE_EXCEPTION(TabError, IndentationError)
176 */
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000177 MP_DEFINE_EXCEPTION(SystemError, Exception)
178 MP_DEFINE_EXCEPTION(TypeError, Exception)
179 MP_DEFINE_EXCEPTION(ValueError, Exception)
180 //TODO: Implement UnicodeErrors which take arguments
Damien Georgec9109722014-03-22 23:40:02 +0000181 /*
Rachel Dowdall721c55d2014-03-22 15:28:16 +0000182 MP_DEFINE_EXCEPTION(Warning, Exception)
183 MP_DEFINE_EXCEPTION_BASE(Warning)
184 MP_DEFINE_EXCEPTION(DeprecationWarning, Warning)
185 MP_DEFINE_EXCEPTION(PendingDeprecationWarning, Warning)
186 MP_DEFINE_EXCEPTION(RuntimeWarning, Warning)
187 MP_DEFINE_EXCEPTION(SyntaxWarning, Warning)
188 MP_DEFINE_EXCEPTION(UserWarning, Warning)
189 MP_DEFINE_EXCEPTION(FutureWarning, Warning)
190 MP_DEFINE_EXCEPTION(ImportWarning, Warning)
191 MP_DEFINE_EXCEPTION(UnicodeWarning, Warning)
192 MP_DEFINE_EXCEPTION(BytesWarning, Warning)
193 MP_DEFINE_EXCEPTION(ResourceWarning, Warning)
Damien Georgec9109722014-03-22 23:40:02 +0000194 */
Damien Georgec5966122014-02-15 16:10:44 +0000195
196mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type) {
Paul Sokolovskya96d3d02014-03-31 01:10:10 +0300197 return mp_obj_new_exception_args(exc_type, 0, NULL);
Damiend99b0522013-12-21 18:17:45 +0000198}
199
Paul Sokolovskydec31bb2014-04-22 00:01:13 +0300200// "Optimized" version for common(?) case of having 1 exception arg
201mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg) {
202 return mp_obj_new_exception_args(exc_type, 1, &arg);
203}
204
Paul Sokolovsky962b1cd2014-03-23 21:48:29 +0200205mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, uint n_args, const mp_obj_t *args) {
206 assert(exc_type->make_new == mp_obj_exception_make_new);
207 return exc_type->make_new((mp_obj_t)exc_type, n_args, 0, args);
208}
209
Damien Georgec5966122014-02-15 16:10:44 +0000210mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg) {
211 return mp_obj_new_exception_msg_varg(exc_type, msg);
Damiend99b0522013-12-21 18:17:45 +0000212}
213
Damien Georgec5966122014-02-15 16:10:44 +0000214mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...) {
215 // check that the given type is an exception type
216 assert(exc_type->make_new == mp_obj_exception_make_new);
217
Damien George6c73ca12014-01-08 18:11:23 +0000218 // make exception object
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300219 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 +0100220 if (o == NULL) {
221 // Couldn't allocate heap memory; use local data instead.
222 // Unfortunately, we won't be able to format the string...
223 o = &mp_emergency_exception_obj;
224 o->base.type = exc_type;
225 o->traceback = MP_OBJ_NULL;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300226 o->args = mp_const_empty_tuple;
Paul Sokolovskyddf21782014-01-12 23:30:20 +0200227 } else {
Damien Georgef0954e32014-04-10 14:38:25 +0100228 o->base.type = exc_type;
229 o->traceback = MP_OBJ_NULL;
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300230 o->args = mp_obj_new_tuple(1, NULL);
Damien Georgef0954e32014-04-10 14:38:25 +0100231
232 if (fmt == NULL) {
233 // no message
234 assert(0);
235 } else {
236 // render exception message and store as .args[0]
237 // TODO: optimize bufferbloat
238 vstr_t *vstr = vstr_new();
239 va_list ap;
240 va_start(ap, fmt);
241 vstr_vprintf(vstr, fmt, ap);
242 va_end(ap);
Paul Sokolovsky1acf22f2014-04-23 02:19:18 +0300243 o->args->items[0] = mp_obj_new_str((byte*)vstr->buf, vstr->len, false);
Damien Georgef0954e32014-04-10 14:38:25 +0100244 vstr_free(vstr);
245 }
Damien George6c73ca12014-01-08 18:11:23 +0000246 }
Damien George6c73ca12014-01-08 18:11:23 +0000247
248 return o;
249}
250
Damien Georgec5966122014-02-15 16:10:44 +0000251// return true if the given object is an exception type
Damien Georgec5966122014-02-15 16:10:44 +0000252bool mp_obj_is_exception_type(mp_obj_t self_in) {
253 if (MP_OBJ_IS_TYPE(self_in, &mp_type_type)) {
Damien George9e6e9352014-03-26 18:37:06 +0000254 // optimisation when self_in is a builtin exception
Damien Georgec5966122014-02-15 16:10:44 +0000255 mp_obj_type_t *self = self_in;
Damien George9e6e9352014-03-26 18:37:06 +0000256 if (self->make_new == mp_obj_exception_make_new) {
257 return true;
258 }
Damien Georgec5966122014-02-15 16:10:44 +0000259 }
Damien George9e6e9352014-03-26 18:37:06 +0000260 return mp_obj_is_subclass_fast(self_in, &mp_type_BaseException);
Damien Georgec5966122014-02-15 16:10:44 +0000261}
262
263// return true if the given object is an instance of an exception type
Damien Georgec5966122014-02-15 16:10:44 +0000264bool mp_obj_is_exception_instance(mp_obj_t self_in) {
Damien George9e6e9352014-03-26 18:37:06 +0000265 return mp_obj_is_exception_type(mp_obj_get_type(self_in));
Damien Georgec5966122014-02-15 16:10:44 +0000266}
267
Paul Sokolovsky962b1cd2014-03-23 21:48:29 +0200268// return true if exception (type or instance) is a subclass of given
269// exception type.
270bool mp_obj_exception_match(mp_obj_t exc, const mp_obj_type_t *exc_type) {
271 // TODO: move implementation from RT_BINARY_OP_EXCEPTION_MATCH here.
Damien Georged17926d2014-03-30 13:35:08 +0100272 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 +0200273}
274
Paul Sokolovsky91e556a2014-05-02 02:27:00 +0300275// traceback handling functions
Damien Georgec5966122014-02-15 16:10:44 +0000276
Paul Sokolovsky91e556a2014-05-02 02:27:00 +0300277#define GET_NATIVE_EXCEPTION(self, self_in) \
278 /* make sure self_in is an exception instance */ \
279 assert(mp_obj_is_exception_instance(self_in)); \
280 mp_obj_exception_t *self; \
281 if (mp_obj_is_native_exception_instance(self_in)) { \
282 self = self_in; \
283 } else { \
284 self = ((mp_obj_instance_t*)self_in)->subobj[0]; \
Damien George9e6e9352014-03-26 18:37:06 +0000285 }
Paul Sokolovsky91e556a2014-05-02 02:27:00 +0300286
287void mp_obj_exception_clear_traceback(mp_obj_t self_in) {
288 GET_NATIVE_EXCEPTION(self, self_in);
289 // just set the traceback to the null object
290 // we don't want to call any memory management functions here
291 self->traceback = MP_OBJ_NULL;
Damienb86e3f92013-12-29 17:17:43 +0000292}
Damien George08335002014-01-18 23:24:36 +0000293
Damien George136b1492014-01-19 12:38:49 +0000294void mp_obj_exception_add_traceback(mp_obj_t self_in, qstr file, machine_uint_t line, qstr block) {
Paul Sokolovsky91e556a2014-05-02 02:27:00 +0300295 GET_NATIVE_EXCEPTION(self, self_in);
Damien Georgec5966122014-02-15 16:10:44 +0000296
Paul Sokolovsky91e556a2014-05-02 02:27:00 +0300297 // for traceback, we are just using the list object for convenience, it's not really a list of Python objects
298 if (self->traceback == MP_OBJ_NULL) {
299 self->traceback = mp_obj_new_list(0, NULL);
Damien George08335002014-01-18 23:24:36 +0000300 }
Paul Sokolovsky91e556a2014-05-02 02:27:00 +0300301 mp_obj_list_append(self->traceback, (mp_obj_t)(machine_uint_t)file);
302 mp_obj_list_append(self->traceback, (mp_obj_t)(machine_uint_t)line);
303 mp_obj_list_append(self->traceback, (mp_obj_t)(machine_uint_t)block);
Damien George08335002014-01-18 23:24:36 +0000304}
305
Damien George136b1492014-01-19 12:38:49 +0000306void mp_obj_exception_get_traceback(mp_obj_t self_in, machine_uint_t *n, machine_uint_t **values) {
Paul Sokolovsky91e556a2014-05-02 02:27:00 +0300307 GET_NATIVE_EXCEPTION(self, self_in);
Damien Georgec5966122014-02-15 16:10:44 +0000308
Damien George136b1492014-01-19 12:38:49 +0000309 if (self->traceback == MP_OBJ_NULL) {
310 *n = 0;
311 *values = NULL;
312 } else {
313 uint n2;
314 mp_obj_list_get(self->traceback, &n2, (mp_obj_t**)values);
315 *n = n2;
316 }
Damien George08335002014-01-18 23:24:36 +0000317}