@@ -170,6 +170,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, m
170170
171171STATIC mp_obj_t str_subscr (mp_obj_t self_in , mp_obj_t index , mp_obj_t value ) {
172172 mp_obj_type_t * type = mp_obj_get_type (self_in );
173+ assert (type == & mp_type_str );
173174 GET_STR_DATA_LEN (self_in , self_data , self_len );
174175 if (value == MP_OBJ_SENTINEL ) {
175176 // load
@@ -182,22 +183,6 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
182183 "only slices with step=1 (aka None) are supported" ));
183184 }
184185
185- if (type == & mp_type_bytes ) {
186- mp_int_t start = 0 , stop = self_len ;
187- if (ostart != mp_const_none ) {
188- start = MP_OBJ_SMALL_INT_VALUE (ostart );
189- if (start < 0 ) {
190- start = self_len + start ;
191- }
192- }
193- if (ostop != mp_const_none ) {
194- stop = MP_OBJ_SMALL_INT_VALUE (ostop );
195- if (stop < 0 ) {
196- stop = self_len + stop ;
197- }
198- }
199- return mp_obj_new_str_of_type (type , self_data + start , stop - start );
200- }
201186 const byte * pstart , * pstop ;
202187 if (ostart != mp_const_none ) {
203188 pstart = str_index_to_ptr (type , self_data , self_len , ostart , true);
@@ -217,10 +202,6 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
217202 return mp_obj_new_str_of_type (type , (const byte * )pstart , pstop - pstart );
218203 }
219204#endif
220- if (type == & mp_type_bytes ) {
221- uint index_val = mp_get_index (type , self_len , index , false);
222- return MP_OBJ_NEW_SMALL_INT (self_data [index_val ]);
223- }
224205 const byte * s = str_index_to_ptr (type , self_data , self_len , index , false);
225206 int len = 1 ;
226207 if (UTF8_IS_NONASCII (* s )) {
0 commit comments