@@ -233,8 +233,7 @@ mp_int_t mp_obj_get_int(mp_const_obj_t arg) {
233
233
return mp_obj_int_get_checked (arg );
234
234
} else {
235
235
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
236
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
237
- "can't convert to int" ));
236
+ mp_raise_msg (& mp_type_TypeError , "can't convert to int" );
238
237
} else {
239
238
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
240
239
"can't convert %s to int" , mp_obj_get_type_str (arg )));
@@ -282,8 +281,7 @@ mp_float_t mp_obj_get_float(mp_obj_t arg) {
282
281
return mp_obj_float_get (arg );
283
282
} else {
284
283
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
285
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
286
- "can't convert to float" ));
284
+ mp_raise_msg (& mp_type_TypeError , "can't convert to float" );
287
285
} else {
288
286
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
289
287
"can't convert %s to float" , mp_obj_get_type_str (arg )));
@@ -312,8 +310,7 @@ void mp_obj_get_complex(mp_obj_t arg, mp_float_t *real, mp_float_t *imag) {
312
310
mp_obj_complex_get (arg , real , imag );
313
311
} else {
314
312
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
315
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
316
- "can't convert to complex" ));
313
+ mp_raise_msg (& mp_type_TypeError , "can't convert to complex" );
317
314
} else {
318
315
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
319
316
"can't convert %s to complex" , mp_obj_get_type_str (arg )));
@@ -331,8 +328,7 @@ void mp_obj_get_array(mp_obj_t o, mp_uint_t *len, mp_obj_t **items) {
331
328
mp_obj_list_get (o , len , items );
332
329
} else {
333
330
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
334
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
335
- "expected tuple/list" ));
331
+ mp_raise_msg (& mp_type_TypeError , "expected tuple/list" );
336
332
} else {
337
333
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
338
334
"object '%s' is not a tuple or list" , mp_obj_get_type_str (o )));
@@ -346,8 +342,7 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, mp_uint_t len, mp_obj_t **items) {
346
342
mp_obj_get_array (o , & seq_len , items );
347
343
if (seq_len != len ) {
348
344
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
349
- nlr_raise (mp_obj_new_exception_msg (& mp_type_ValueError ,
350
- "tuple/list has wrong length" ));
345
+ mp_raise_msg (& mp_type_ValueError , "tuple/list has wrong length" );
351
346
} else {
352
347
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_ValueError ,
353
348
"requested length %d but object has length %d" , (int )len , (int )seq_len ));
@@ -362,8 +357,7 @@ mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index,
362
357
i = MP_OBJ_SMALL_INT_VALUE (index );
363
358
} else if (!mp_obj_get_int_maybe (index , & i )) {
364
359
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
365
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
366
- "indices must be integers" ));
360
+ mp_raise_msg (& mp_type_TypeError , "indices must be integers" );
367
361
} else {
368
362
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
369
363
"%q indices must be integers, not %s" ,
@@ -383,7 +377,7 @@ mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index,
383
377
} else {
384
378
if (i < 0 || (mp_uint_t )i >= len ) {
385
379
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
386
- nlr_raise ( mp_obj_new_exception_msg ( & mp_type_IndexError , "index out of range" ) );
380
+ mp_raise_msg ( & mp_type_IndexError , "index out of range" );
387
381
} else {
388
382
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_IndexError ,
389
383
"%q index out of range" , type -> name ));
@@ -416,8 +410,7 @@ mp_obj_t mp_obj_len(mp_obj_t o_in) {
416
410
mp_obj_t len = mp_obj_len_maybe (o_in );
417
411
if (len == MP_OBJ_NULL ) {
418
412
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
419
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
420
- "object has no len" ));
413
+ mp_raise_msg (& mp_type_TypeError , "object has no len" );
421
414
} else {
422
415
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
423
416
"object of type '%s' has no len()" , mp_obj_get_type_str (o_in )));
@@ -458,8 +451,7 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
458
451
}
459
452
if (value == MP_OBJ_NULL ) {
460
453
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
461
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
462
- "object does not support item deletion" ));
454
+ mp_raise_msg (& mp_type_TypeError , "object does not support item deletion" );
463
455
} else {
464
456
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
465
457
"'%s' object does not support item deletion" , mp_obj_get_type_str (base )));
@@ -474,8 +466,7 @@ mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value) {
474
466
}
475
467
} else {
476
468
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE ) {
477
- nlr_raise (mp_obj_new_exception_msg (& mp_type_TypeError ,
478
- "object does not support item assignment" ));
469
+ mp_raise_msg (& mp_type_TypeError , "object does not support item assignment" );
479
470
} else {
480
471
nlr_raise (mp_obj_new_exception_msg_varg (& mp_type_TypeError ,
481
472
"'%s' object does not support item assignment" , mp_obj_get_type_str (base )));
@@ -504,7 +495,7 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
504
495
505
496
void mp_get_buffer_raise (mp_obj_t obj , mp_buffer_info_t * bufinfo , mp_uint_t flags ) {
506
497
if (!mp_get_buffer (obj , bufinfo , flags )) {
507
- nlr_raise ( mp_obj_new_exception_msg ( & mp_type_TypeError , "object with buffer protocol required" ) );
498
+ mp_raise_msg ( & mp_type_TypeError , "object with buffer protocol required" );
508
499
}
509
500
}
510
501
0 commit comments