Browse Source
Decimal('sNaN') is a valid Decimal value but float(Decimal('sNaN'))
raises ValueError. The else branch in decimal_encoder always called
float(), so any signaling NaN value reaching jsonable_encoder caused
an unhandled crash.
Fix: wrap the float() call in a try/except ValueError and fall back to
float('nan') for signaling NaN, consistent with the existing behaviour
for Decimal('NaN') (quiet NaN).
Added test_decimal_encoder_signaling_nan to cover the regression.
pull/15783/head
2 changed files with 17 additions and 1 deletions
Loading…
Reference in new issue