summaryrefslogtreecommitdiff
path: root/py/builtin.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-20 20:32:50 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-20 20:37:01 +0200
commita80ff04fe7458b8ed8e948619b3700b720832ec2 (patch)
tree8f78e879e523c609c36475bf14bde8043c2719fb /py/builtin.c
parentf0cfb8cb45cb1fc91c77fae98f5452b7f7865392 (diff)
Add dummy bytes() constructor.
Currently, MicroPython strings are mix between CPython byte and unicode strings. So, conversion is null so far. This dummy implementation is intended for compatibility with CPython (so, same code can run on both).
Diffstat (limited to 'py/builtin.c')
-rw-r--r--py/builtin.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/py/builtin.c b/py/builtin.c
index f102aa588..13463ada6 100644
--- a/py/builtin.c
+++ b/py/builtin.c
@@ -347,3 +347,15 @@ static mp_obj_t mp_builtin_str(mp_obj_t o_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_str_obj, mp_builtin_str);
+
+// TODO: This should be type, this is just quick CPython compat hack
+static mp_obj_t mp_builtin_bytes(uint n_args, const mp_obj_t *args) {
+ if (!MP_OBJ_IS_QSTR(args[0]) && !MP_OBJ_IS_TYPE(args[0], &str_type)) {
+ assert(0);
+ }
+ // Currently, MicroPython strings are mix between CPython byte and unicode
+ // strings. So, conversion is null so far.
+ return args[0];
+}
+
+MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_bytes_obj, 1, 3, mp_builtin_bytes);