diff options
Diffstat (limited to 'py/objstr.c')
| -rw-r--r-- | py/objstr.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/py/objstr.c b/py/objstr.c index f082e9559..c34b756e5 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -400,7 +400,7 @@ STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) { mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(self_len, index, &slice)) { - mp_not_implemented("only slices with step=1 (aka None) are supported"); + mp_raise_NotImplementError("only slices with step=1 (aka None) are supported"); } return mp_obj_new_str_of_type(type, self_data + slice.start, slice.stop - slice.start); } @@ -609,7 +609,7 @@ STATIC mp_obj_t str_rsplit(size_t n_args, const mp_obj_t *args) { mp_int_t idx = splits; if (sep == mp_const_none) { - mp_not_implemented("rsplit(None,n)"); + mp_raise_NotImplementError("rsplit(None,n)"); } else { mp_uint_t sep_len; const char *sep_str = mp_obj_str_get_data(sep, &sep_len); @@ -727,7 +727,7 @@ STATIC mp_obj_t str_endswith(size_t n_args, const mp_obj_t *args) { GET_STR_DATA_LEN(args[0], str, str_len); GET_STR_DATA_LEN(args[1], suffix, suffix_len); if (n_args > 2) { - mp_not_implemented("start/end indices"); + mp_raise_NotImplementError("start/end indices"); } if (suffix_len > str_len) { @@ -950,8 +950,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar mp_raise_ValueError( "end of format while looking for conversion specifier"); } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, - "unknown conversion specifier %c", *str)); + mp_raise_ValueError_varg("unknown conversion specifier %c", *str); } } } @@ -1008,7 +1007,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar } field_name = str_to_int(field_name, field_name_top, &index); if ((uint)index >= n_args - 1) { - mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); + mp_raise_IndexError("tuple index out of range"); } arg = args[index + 1]; *arg_i = -1; @@ -1024,7 +1023,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar arg = key_elem->value; } if (field_name < field_name_top) { - mp_not_implemented("attributes not supported yet"); + mp_raise_NotImplementError("attributes not supported yet"); } } else { if (*arg_i < 0) { @@ -1036,7 +1035,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar } } if ((uint)*arg_i >= n_args - 1) { - mp_raise_msg(&mp_type_IndexError, "tuple index out of range"); + mp_raise_IndexError("tuple index out of range"); } arg = args[(*arg_i) + 1]; (*arg_i)++; @@ -1214,9 +1213,9 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { terse_str_format_value_error(); } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + mp_raise_ValueError_varg( "unknown format code '%c' for object of type '%s'", - type, mp_obj_get_type_str(arg))); + type, mp_obj_get_type_str(arg)); } } } @@ -1286,9 +1285,9 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { terse_str_format_value_error(); } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + mp_raise_ValueError_varg( "unknown format code '%c' for object of type 'float'", - type, mp_obj_get_type_str(arg))); + type, mp_obj_get_type_str(arg)); } } } else { @@ -1322,9 +1321,9 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { terse_str_format_value_error(); } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + mp_raise_ValueError_varg( "unknown format code '%c' for object of type 'str'", - type, mp_obj_get_type_str(arg))); + type, mp_obj_get_type_str(arg)); } } } @@ -1520,9 +1519,9 @@ not_enough_args: if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { terse_str_format_value_error(); } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, + mp_raise_ValueError_varg( "unsupported format character '%c' (0x%x) at index %d", - *str, *str, str - start_str)); + *str, *str, str - start_str); } } } @@ -2061,9 +2060,9 @@ STATIC void bad_implicit_conversion(mp_obj_t self_in) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_TypeError("can't convert to str implicitly"); } else { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, + mp_raise_TypeError_varg( "can't convert '%s' object to str implicitly", - mp_obj_get_type_str(self_in))); + mp_obj_get_type_str(self_in)); } } |
