summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-04-04 19:42:03 +0100
committerDamien George <damien.p.george@gmail.com>2015-04-04 19:42:03 +0100
commit0528c5a22a7668e3056a0e3005bf96358df2c52b (patch)
treec44a35cbe90de3c2fa79c833b09d69626109ddf1 /py
parent0f6424efda0bc8214ac0036cd29c47ef2f92245d (diff)
downloadmicropython-0528c5a22a7668e3056a0e3005bf96358df2c52b.tar.gz
micropython-0528c5a22a7668e3056a0e3005bf96358df2c52b.zip
py: In str unicode, str_subscr will never be passed a bytes object.
Diffstat (limited to 'py')
-rw-r--r--py/objstrunicode.c21
1 files changed, 1 insertions, 20 deletions
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 4e7f770c30..406eaad49f 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -170,6 +170,7 @@ const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, m
STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
mp_obj_type_t *type = mp_obj_get_type(self_in);
+ assert(type == &mp_type_str);
GET_STR_DATA_LEN(self_in, self_data, self_len);
if (value == MP_OBJ_SENTINEL) {
// load
@@ -182,22 +183,6 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
"only slices with step=1 (aka None) are supported"));
}
- if (type == &mp_type_bytes) {
- mp_int_t start = 0, stop = self_len;
- if (ostart != mp_const_none) {
- start = MP_OBJ_SMALL_INT_VALUE(ostart);
- if (start < 0) {
- start = self_len + start;
- }
- }
- if (ostop != mp_const_none) {
- stop = MP_OBJ_SMALL_INT_VALUE(ostop);
- if (stop < 0) {
- stop = self_len + stop;
- }
- }
- return mp_obj_new_str_of_type(type, self_data + start, stop - start);
- }
const byte *pstart, *pstop;
if (ostart != mp_const_none) {
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) {
return mp_obj_new_str_of_type(type, (const byte *)pstart, pstop - pstart);
}
#endif
- if (type == &mp_type_bytes) {
- uint index_val = mp_get_index(type, self_len, index, false);
- return MP_OBJ_NEW_SMALL_INT(self_data[index_val]);
- }
const byte *s = str_index_to_ptr(type, self_data, self_len, index, false);
int len = 1;
if (UTF8_IS_NONASCII(*s)) {