diff options
author | Damien George <damien.p.george@gmail.com> | 2017-07-04 02:15:11 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-07-04 02:15:11 +1000 |
commit | 6b8b56f8596d3dde544a72d037e9feddd9f70938 (patch) | |
tree | 2f38350492210f01e6347e3e9332f8f37e4be3b9 /py/modmath.c | |
parent | 9ed5e80eea71c8392b7c178d2e2b69e2428850d8 (diff) | |
download | micropython-6b8b56f8596d3dde544a72d037e9feddd9f70938.tar.gz micropython-6b8b56f8596d3dde544a72d037e9feddd9f70938.zip |
py/modmath: Check for zero division in log with 2 args.
Diffstat (limited to 'py/modmath.c')
-rw-r--r-- | py/modmath.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/py/modmath.c b/py/modmath.c index 10713234c7..d5d135fc11 100644 --- a/py/modmath.c +++ b/py/modmath.c @@ -168,6 +168,8 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) { mp_float_t base = mp_obj_get_float(args[1]); if (base <= (mp_float_t)0.0) { math_error(); + } else if (base == (mp_float_t)1.0) { + mp_raise_msg(&mp_type_ZeroDivisionError, "division by zero"); } return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base)); } |