summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
Diffstat (limited to 'py')
-rw-r--r--py/builtin.c6
-rw-r--r--py/builtinevex.c4
-rw-r--r--py/builtinimport.c4
-rw-r--r--py/obj.h2
-rw-r--r--py/objarray.c2
-rw-r--r--py/objint.c8
-rw-r--r--py/objstr.c4
-rw-r--r--py/stream.c2
8 files changed, 17 insertions, 15 deletions
diff --git a/py/builtin.c b/py/builtin.c
index ff248f87c3..b0599bc4b5 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));
}
diff --git a/py/builtinevex.c b/py/builtinevex.c
index 03db862738..54c3f743e3 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -21,10 +21,10 @@
static mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) {
uint str_len;
- const byte *str = mp_obj_str_get_data(o_in, &str_len);
+ const char *str = mp_obj_str_get_data(o_in, &str_len);
// create the lexer
- mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, (const char*)str, str_len, 0);
+ mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_string_gt_, str, str_len, 0);
qstr source_name = mp_lexer_source_name(lex);
// parse the string
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 1ef7be8702..0e44676c3b 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -54,9 +54,9 @@ mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) {
for (int i = 0; i < path_num; i++) {
vstr_reset(dest);
uint p_len;
- const byte *p = mp_obj_str_get_data(path_items[i], &p_len);
+ const char *p = mp_obj_str_get_data(path_items[i], &p_len);
if (p_len > 0) {
- vstr_add_strn(dest, (const char*)p, p_len);
+ vstr_add_strn(dest, p, p_len);
vstr_add_char(dest, PATH_SEP_CHAR);
}
vstr_add_strn(dest, file_str, file_len);
diff --git a/py/obj.h b/py/obj.h
index 660ac6627c..f99bcc40e7 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -290,7 +290,7 @@ uint mp_obj_str_get_hash(mp_obj_t self_in);
uint mp_obj_str_get_len(mp_obj_t self_in);
qstr mp_obj_str_get_qstr(mp_obj_t self_in); // use this if you will anyway convert the string to a qstr
const char *mp_obj_str_get_str(mp_obj_t self_in); // use this only if you need the string to be null terminated
-const byte *mp_obj_str_get_data(mp_obj_t self_in, uint *len);
+const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len);
void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, uint str_len);
// bytes
diff --git a/py/objarray.c b/py/objarray.c
index c595d217c1..75ed399d20 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -174,7 +174,7 @@ static mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
}
// TODO check args
uint l;
- const byte *typecode = mp_obj_str_get_data(args[0], &l);
+ const char *typecode = mp_obj_str_get_data(args[0], &l);
if (n_args == 1) {
return array_new(*typecode, 0);
}
diff --git a/py/objint.c b/py/objint.c
index 1a04408afd..fdcc43807a 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -23,8 +23,8 @@ static mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
if (MP_OBJ_IS_STR(args[0])) {
// a string, parse it
uint l;
- const byte *s = mp_obj_str_get_data(args[0], &l);
- return MP_OBJ_NEW_SMALL_INT(strtonum((const char*)s, 0));
+ const char *s = mp_obj_str_get_data(args[0], &l);
+ return MP_OBJ_NEW_SMALL_INT(strtonum(s, 0));
} else {
return MP_OBJ_NEW_SMALL_INT(mp_obj_get_int(args[0]));
}
@@ -34,8 +34,8 @@ static mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
// should be a string, parse it
// TODO proper error checking of argument types
uint l;
- const byte *s = mp_obj_str_get_data(args[0], &l);
- return MP_OBJ_NEW_SMALL_INT(strtonum((const char*)s, mp_obj_get_int(args[1])));
+ const char *s = mp_obj_str_get_data(args[0], &l);
+ return MP_OBJ_NEW_SMALL_INT(strtonum(s, mp_obj_get_int(args[1])));
}
default:
diff --git a/py/objstr.c b/py/objstr.c
index 03602b6ec7..81e0d65b3b 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -635,11 +635,11 @@ const char *mp_obj_str_get_str(mp_obj_t self_in) {
}
}
-const byte *mp_obj_str_get_data(mp_obj_t self_in, uint *len) {
+const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len) {
if (MP_OBJ_IS_STR(self_in)) {
GET_STR_DATA_LEN(self_in, s, l);
*len = l;
- return s;
+ return (const char*)s;
} else {
bad_implicit_conversion(self_in);
}
diff --git a/py/stream.c b/py/stream.c
index c97c711f0f..10c7d88c0d 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -43,7 +43,7 @@ static mp_obj_t stream_write(mp_obj_t self_in, mp_obj_t arg) {
}
uint sz;
- const byte *buf = mp_obj_str_get_data(arg, &sz);
+ const char *buf = mp_obj_str_get_data(arg, &sz);
int error;
machine_int_t out_sz = o->type->stream_p.write(self_in, buf, sz, &error);
if (out_sz == -1) {