summaryrefslogtreecommitdiff
path: root/py/binary.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/py/binary.c b/py/binary.c
index 927a42640..8b5c05ab3 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -32,6 +32,7 @@
#include "py/binary.h"
#include "py/smallint.h"
+#include "py/objint.h"
// Helpers to work with binary-encoded data
@@ -282,10 +283,13 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
}
#endif
default:
- // we handle large ints here by calling the truncated accessor
+ #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) {
- val = mp_obj_int_get_truncated(val_in);
- } else {
+ mp_obj_int_to_bytes_impl(val_in, struct_type == '>', size, p);
+ return;
+ } else
+ #endif
+ {
val = mp_obj_get_int(val_in);
}
}