summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorxyb <xieyanbo@gmail.com>2014-01-14 22:43:18 +0800
committerxyb <xieyanbo@gmail.com>2014-01-14 22:43:18 +0800
commit82e61bdc24eb1d70a342c65e06de113e7375e361 (patch)
treedf38361299ebd499cc99b3c1fd989dbf6cac930b
parentc178ea471ee30f32439741181d30d6a89830aabf (diff)
downloadmicropython-82e61bdc24eb1d70a342c65e06de113e7375e361.tar.gz
micropython-82e61bdc24eb1d70a342c65e06de113e7375e361.zip
support int(str, basbase)
-rw-r--r--py/obj.c2
-rw-r--r--py/objint.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/py/obj.c b/py/obj.c
index 73ffe5281f..866b9aaefa 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -158,7 +158,7 @@ machine_int_t mp_obj_get_int_base(mp_obj_t arg, mp_obj_t base_arg) {
if (base_arg == 0) {
value = qstr_str(mp_obj_str_get(arg));
return (machine_int_t)strtonum(value, 0);
- } else if (MP_OBJ_IS_TYPE(base_arg, &int_type)) {
+ } else if (MP_OBJ_IS_SMALL_INT(base_arg)) {
base = MP_OBJ_SMALL_INT_VALUE(base_arg);
value = qstr_str(mp_obj_str_get(arg));
return (machine_int_t)strtonum(value, base);
diff --git a/py/objint.c b/py/objint.c
index 58fc37b3bb..e5351ce3a1 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -24,7 +24,7 @@ static mp_obj_t int_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args)
case 2:
// TODO make args[0] and args[1] correct
- return MP_OBJ_NEW_SMALL_INT(mp_obj_get_int_base(args[0], args[1]));
+ return MP_OBJ_NEW_SMALL_INT(mp_obj_get_int_base(args[1], args[0]));
default:
nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "int takes at most 2 arguments, %d given", (void*)(machine_int_t)n_args));