Kaydet (Commit) c886f3de authored tarafından Fabio Bonelli's avatar Fabio Bonelli Kaydeden (comit) Tim Graham

Fixed #29006 -- Fixed DecimalField.clean() crash on sNaN values.

üst 1c95737e
......@@ -351,7 +351,7 @@ class DecimalField(IntegerField):
super().validate(value)
if value in self.empty_values:
return
if not math.isfinite(value):
if value.is_nan() or not math.isfinite(value):
raise ValidationError(self.error_messages['invalid'], code='invalid')
def widget_attrs(self, widget):
......
......@@ -51,6 +51,7 @@ class DecimalFieldTest(FormFieldAssertionsMixin, SimpleTestCase):
f = DecimalField(max_digits=4, decimal_places=2)
values = (
'-NaN', 'NaN', '+NaN',
'-sNaN', 'sNaN', '+sNaN',
'-Inf', 'Inf', '+Inf',
'-Infinity', 'Infinity', '+Infinity',
'a', 'łąść', '1.0a', '--0.12',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment