@@ -540,7 +540,8 @@ enum { LSTRIP, RSTRIP, STRIP };
540
540
541
541
STATIC mp_obj_t str_uni_strip (int type , uint n_args , const mp_obj_t * args ) {
542
542
assert (1 <= n_args && n_args <= 2 );
543
- assert (MP_OBJ_IS_STR (args [0 ]));
543
+ assert (is_str_or_bytes (args [0 ]));
544
+ const mp_obj_type_t * self_type = mp_obj_get_type (args [0 ]);
544
545
545
546
const byte * chars_to_del ;
546
547
uint chars_to_del_len ;
@@ -550,7 +551,9 @@ STATIC mp_obj_t str_uni_strip(int type, uint n_args, const mp_obj_t *args) {
550
551
chars_to_del = whitespace ;
551
552
chars_to_del_len = sizeof (whitespace );
552
553
} else {
553
- assert (MP_OBJ_IS_STR (args [1 ]));
554
+ if (mp_obj_get_type (args [1 ]) != self_type ) {
555
+ arg_type_mixup ();
556
+ }
554
557
GET_STR_DATA_LEN (args [1 ], s , l );
555
558
chars_to_del = s ;
556
559
chars_to_del_len = l ;
@@ -594,7 +597,7 @@ STATIC mp_obj_t str_uni_strip(int type, uint n_args, const mp_obj_t *args) {
594
597
assert (last_good_char_pos >= first_good_char_pos );
595
598
//+1 to accomodate the last character
596
599
machine_uint_t stripped_len = last_good_char_pos - first_good_char_pos + 1 ;
597
- return mp_obj_new_str ( orig_str + first_good_char_pos , stripped_len , false );
600
+ return str_new ( self_type , orig_str + first_good_char_pos , stripped_len );
598
601
}
599
602
600
603
STATIC mp_obj_t str_strip (uint n_args , const mp_obj_t * args ) {
0 commit comments