Skip to content

Commit e98ff40

Browse files
committed
py/modbuiltins: Simplify casts from char to byte ptr in builtin ord.
1 parent 19aee94 commit e98ff40

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

py/modbuiltins.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,19 +343,19 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
343343

344344
STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
345345
size_t len;
346-
const char *str = mp_obj_str_get_data(o_in, &len);
346+
const byte *str = (const byte*)mp_obj_str_get_data(o_in, &len);
347347
#if MICROPY_PY_BUILTINS_STR_UNICODE
348348
if (MP_OBJ_IS_STR(o_in)) {
349-
len = utf8_charlen((const byte*)str, len);
349+
len = utf8_charlen(str, len);
350350
if (len == 1) {
351-
return mp_obj_new_int(utf8_get_char((const byte*)str));
351+
return mp_obj_new_int(utf8_get_char(str));
352352
}
353353
} else
354354
#endif
355355
{
356356
// a bytes object, or a str without unicode support (don't sign extend the char)
357357
if (len == 1) {
358-
return MP_OBJ_NEW_SMALL_INT(((const byte*)str)[0]);
358+
return MP_OBJ_NEW_SMALL_INT(str[0]);
359359
}
360360
}
361361

0 commit comments

Comments
 (0)