@@ -63,6 +63,10 @@ STATIC void str_check_arg_type(const mp_obj_type_t *self_type, const mp_obj_t ar
63
63
}
64
64
}
65
65
66
+ STATIC void check_is_str_or_bytes (mp_obj_t self_in ) {
67
+ mp_check_self (mp_obj_is_str_or_bytes (self_in ));
68
+ }
69
+
66
70
/******************************************************************************/
67
71
/* str */
68
72
@@ -468,7 +472,7 @@ STATIC mp_obj_t bytes_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
468
472
}
469
473
470
474
STATIC mp_obj_t str_join (mp_obj_t self_in , mp_obj_t arg ) {
471
- mp_check_self ( mp_obj_is_str_or_bytes ( self_in ) );
475
+ check_is_str_or_bytes ( self_in );
472
476
const mp_obj_type_t * self_type = mp_obj_get_type (self_in );
473
477
const mp_obj_type_t * ret_type = self_type ;
474
478
@@ -724,7 +728,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_rsplit_obj, 1, 3, str_rsplit);
724
728
725
729
STATIC mp_obj_t str_finder (size_t n_args , const mp_obj_t * args , int direction , bool is_index ) {
726
730
const mp_obj_type_t * self_type = mp_obj_get_type (args [0 ]);
727
- mp_check_self ( mp_obj_is_str_or_bytes ( args [0 ]) );
731
+ check_is_str_or_bytes ( args [0 ]);
728
732
729
733
// check argument type
730
734
str_check_arg_type (self_type , args [1 ]);
@@ -820,7 +824,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_endswith_obj, 2, 3, str_endswith);
820
824
enum { LSTRIP , RSTRIP , STRIP };
821
825
822
826
STATIC mp_obj_t str_uni_strip (int type , size_t n_args , const mp_obj_t * args ) {
823
- mp_check_self ( mp_obj_is_str_or_bytes ( args [0 ]) );
827
+ check_is_str_or_bytes ( args [0 ]);
824
828
const mp_obj_type_t * self_type = mp_obj_get_type (args [0 ]);
825
829
826
830
const byte * chars_to_del ;
@@ -1422,7 +1426,7 @@ STATIC vstr_t mp_obj_str_format_helper(const char *str, const char *top, int *ar
1422
1426
}
1423
1427
1424
1428
mp_obj_t mp_obj_str_format (size_t n_args , const mp_obj_t * args , mp_map_t * kwargs ) {
1425
- mp_check_self ( mp_obj_is_str_or_bytes ( args [0 ]) );
1429
+ check_is_str_or_bytes ( args [0 ]);
1426
1430
1427
1431
GET_STR_DATA_LEN (args [0 ], str , len );
1428
1432
int arg_i = 0 ;
@@ -1433,7 +1437,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format);
1433
1437
1434
1438
#if MICROPY_PY_BUILTINS_STR_OP_MODULO
1435
1439
STATIC mp_obj_t str_modulo_format (mp_obj_t pattern , size_t n_args , const mp_obj_t * args , mp_obj_t dict ) {
1436
- mp_check_self ( mp_obj_is_str_or_bytes ( pattern ) );
1440
+ check_is_str_or_bytes ( pattern );
1437
1441
1438
1442
GET_STR_DATA_LEN (pattern , str , len );
1439
1443
#if MICROPY_ERROR_REPORTING > MICROPY_ERROR_REPORTING_TERSE
@@ -1639,7 +1643,7 @@ STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, size_t n_args, const mp_obj_
1639
1643
// The implementation is optimized, returning the original string if there's
1640
1644
// nothing to replace.
1641
1645
STATIC mp_obj_t str_replace (size_t n_args , const mp_obj_t * args ) {
1642
- mp_check_self ( mp_obj_is_str_or_bytes ( args [0 ]) );
1646
+ check_is_str_or_bytes ( args [0 ]);
1643
1647
1644
1648
mp_int_t max_rep = -1 ;
1645
1649
if (n_args == 4 ) {
@@ -1742,7 +1746,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace);
1742
1746
#if MICROPY_PY_BUILTINS_STR_COUNT
1743
1747
STATIC mp_obj_t str_count (size_t n_args , const mp_obj_t * args ) {
1744
1748
const mp_obj_type_t * self_type = mp_obj_get_type (args [0 ]);
1745
- mp_check_self ( mp_obj_is_str_or_bytes ( args [0 ]) );
1749
+ check_is_str_or_bytes ( args [0 ]);
1746
1750
1747
1751
// check argument type
1748
1752
str_check_arg_type (self_type , args [1 ]);
@@ -1782,7 +1786,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_count_obj, 2, 4, str_count);
1782
1786
1783
1787
#if MICROPY_PY_BUILTINS_STR_PARTITION
1784
1788
STATIC mp_obj_t str_partitioner (mp_obj_t self_in , mp_obj_t arg , int direction ) {
1785
- mp_check_self ( mp_obj_is_str_or_bytes ( self_in ) );
1789
+ check_is_str_or_bytes ( self_in );
1786
1790
const mp_obj_type_t * self_type = mp_obj_get_type (self_in );
1787
1791
str_check_arg_type (self_type , arg );
1788
1792
0 commit comments