Fixed #18982 - Caught TypeError in DateField.clean
Thanks gwahl at fusionbox com.
This commit is contained in:
parent
8599f64e54
commit
3174b5f2f5
|
@ -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'])
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue