Commit 3174b5f2 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Fixed #18982 - Caught TypeError in DateField.clean

Thanks gwahl at fusionbox com.
parent 8599f64e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -341,7 +341,7 @@ class BaseTemporalField(Field):
            for format in self.input_formats:
                try:
                    return self.strptime(value, format)
                except ValueError:
                except (ValueError, TypeError):
                    continue
        raise ValidationError(self.error_messages['invalid'])

+5 −0
Original line number Diff line number Diff line
@@ -356,6 +356,11 @@ class FieldsTests(SimpleTestCase):
        self.assertEqual(datetime.date(2006, 10, 25), f.clean(' 25 October 2006 '))
        self.assertRaisesMessage(ValidationError, "'Enter a valid date.'", f.clean, '   ')

    def test_datefield_5(self):
        # Test null bytes (#18982)
        f = DateField()
        self.assertRaisesMessage(ValidationError, "'Enter a valid date.'", f.clean, 'a\x00b')

    # TimeField ###################################################################

    def test_timefield_1(self):