mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 09:36:49 +03:00
Fixed decimal snan deserialization (#7002)
* Added test case causes exception in DecimalField deserialization * Fixed NaN checking which throws exception with sNaN value
This commit is contained in:
parent
a734e58d44
commit
43397a81ae
|
@ -1062,9 +1062,7 @@ class DecimalField(Field):
|
||||||
except decimal.DecimalException:
|
except decimal.DecimalException:
|
||||||
self.fail('invalid')
|
self.fail('invalid')
|
||||||
|
|
||||||
# Check for NaN. It is the only value that isn't equal to itself,
|
if value.is_nan():
|
||||||
# so we can use this to identify NaN values.
|
|
||||||
if value != value:
|
|
||||||
self.fail('invalid')
|
self.fail('invalid')
|
||||||
|
|
||||||
# Check for infinity and negative infinity.
|
# Check for infinity and negative infinity.
|
||||||
|
|
|
@ -1080,6 +1080,7 @@ class TestDecimalField(FieldValues):
|
||||||
invalid_inputs = (
|
invalid_inputs = (
|
||||||
('abc', ["A valid number is required."]),
|
('abc', ["A valid number is required."]),
|
||||||
(Decimal('Nan'), ["A valid number is required."]),
|
(Decimal('Nan'), ["A valid number is required."]),
|
||||||
|
(Decimal('Snan'), ["A valid number is required."]),
|
||||||
(Decimal('Inf'), ["A valid number is required."]),
|
(Decimal('Inf'), ["A valid number is required."]),
|
||||||
('12.345', ["Ensure that there are no more than 3 digits in total."]),
|
('12.345', ["Ensure that there are no more than 3 digits in total."]),
|
||||||
(200000000000.0, ["Ensure that there are no more than 3 digits in total."]),
|
(200000000000.0, ["Ensure that there are no more than 3 digits in total."]),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user