From 208e7ac12510c44775d1631c5310bb6e3988502e Mon Sep 17 00:00:00 2001 From: Sergei Lavrov Date: Thu, 17 Oct 2019 22:03:15 +0300 Subject: [PATCH] Fixed NaN checking which throws exception with sNaN value --- rest_framework/fields.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index c0ceebe3b..ea8f47b2d 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -1062,9 +1062,7 @@ class DecimalField(Field): except decimal.DecimalException: self.fail('invalid') - # Check for NaN. It is the only value that isn't equal to itself, - # so we can use this to identify NaN values. - if value != value: + if value.is_nan(): self.fail('invalid') # Check for infinity and negative infinity.