• Damien George's avatar
    py/modmath: Fix two-argument math function domain check. · 2e4dda3c
    Damien George authored
    
    
    Prior to this fix, pow(1.5, inf) and pow(0.5, -inf) (among other things)
    would incorrectly raise a ValueError, because the result is inf with the
    first argument being finite.  This commit fixes this by allowing the result
    to be infinite if the first or second (or both) argument is infinite.
    
    This fix doesn't affect the other three math functions that have two
    arguments:
    - atan2 never returns inf, so always fails isinf(ans)
    - copysign returns inf only if the first argument x is inf, so will never
      reach the isinf(y) check
    - fmod never returns inf, so always fails isinf(ans)
    Signed-off-by: default avatarDamien George <damien@micropython.org>
    2e4dda3c
modmath.c 16.1 KB