diff options
author | Damien George <damien.p.george@gmail.com> | 2014-07-31 13:41:43 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-07-31 13:41:43 +0000 |
commit | c9aa58e6381018cca2513e3468363af0b5442d1f (patch) | |
tree | 47fa6e3a4971fe4053b08bb085710c325d11bfd0 /py/builtin.c | |
parent | 94fbe9711a1179b3c4d0eb2e9822787d90231719 (diff) |
py: Improve handling of long-int overflow.
This removes mpz_as_int, since that was a terrible function (it
implemented saturating conversion).
Use mpz_as_int_checked and mpz_as_uint_checked. These now work
correctly (they previously had wrong overflow checking, eg
print(chr(10000000000000)) on 32-bit machine would incorrectly convert
this large number to a small int).
Diffstat (limited to 'py/builtin.c')
-rw-r--r-- | py/builtin.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/py/builtin.c b/py/builtin.c index dabc99016..88a724fcd 100644 --- a/py/builtin.c +++ b/py/builtin.c @@ -175,7 +175,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable); STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) { #if MICROPY_PY_BUILTINS_STR_UNICODE - mp_int_t c = mp_obj_get_int(o_in); + mp_uint_t c = mp_obj_get_int(o_in); char str[4]; int len = 0; if (c < 0x80) { |