summaryrefslogtreecommitdiff
path: root/py/builtin.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-02-08 18:17:23 +0000
committerDamien George <damien.p.george@gmail.com>2014-02-08 18:17:23 +0000
commit698ec21e46564ff0c2c71bf11d7eb4ef349c88d9 (patch)
tree3d0eac21ec784f970f9f5586dfbd28c66f0774e5 /py/builtin.c
parent23177088d255bec6c0bf93470aeac77194aa8258 (diff)
Make mp_obj_str_get_data return char* instead of byte*.
Can't decide which is better for string type, char or byte pointer. Changing to char removes a few casts. Really need to do proper unicode.
Diffstat (limited to 'py/builtin.c')
-rw-r--r--py/builtin.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/py/builtin.c b/py/builtin.c
index ff248f87c..b0599bc4b 100644
--- a/py/builtin.c
+++ b/py/builtin.c
@@ -288,9 +288,11 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
static mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
uint len;
- const byte *str = mp_obj_str_get_data(o_in, &len);
+ const char *str = mp_obj_str_get_data(o_in, &len);
if (len == 1) {
- return mp_obj_new_int(str[0]);
+ // don't sign extend when converting to ord
+ // TODO unicode
+ return mp_obj_new_int(((const byte*)str)[0]);
} else {
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "ord() expected a character, but string of length %d found", len));
}