kopia lustrzana https://github.com/micropython/micropython
py/objint: Make length argument optional in int.to_bytes() method.
Signed-off-by: Amirreza Hamzavi <amirrezahamzavi2000@gmail.com>pull/14387/head
rodzic
a167fb4f7f
commit
f8961ea74c
|
@ -424,7 +424,7 @@ static MP_DEFINE_CONST_CLASSMETHOD_OBJ(int_from_bytes_obj, MP_ROM_PTR(&int_from_
|
|||
static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
|
||||
// TODO: Support signed param (assumes signed=False)
|
||||
|
||||
mp_int_t len = mp_obj_get_int(args[1]);
|
||||
mp_int_t len = n_args < 2 ? 1 : mp_obj_get_int(args[1]);
|
||||
if (len < 0) {
|
||||
mp_raise_ValueError(NULL);
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ static mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
|
|||
|
||||
return mp_obj_new_bytes_from_vstr(&vstr);
|
||||
}
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 2, 4, int_to_bytes);
|
||||
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_to_bytes_obj, 1, 4, int_to_bytes);
|
||||
|
||||
static const mp_rom_map_elem_t int_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_from_bytes), MP_ROM_PTR(&int_from_bytes_obj) },
|
||||
|
|
Ładowanie…
Reference in New Issue