Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
82e61bdc
Commit
82e61bdc
authored
Jan 14, 2014
by
xyb
Browse files
support int(str, basbase)
parent
c178ea47
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/obj.c
View file @
82e61bdc
...
...
@@ -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
);
...
...
py/objint.c
View file @
82e61bdc
...
...
@@ -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
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment