Removed unnecessary force_text() in BaseTemporalField.to_python().

This seems unneeded since its introduction in
da3aa22d04.
This commit is contained in:
Tim Graham 2017-01-26 13:35:39 -05:00 committed by GitHub
parent d1bab24e01
commit af598187ec
1 changed files with 7 additions and 11 deletions

View File

@ -390,17 +390,13 @@ class BaseTemporalField(Field):
self.input_formats = input_formats self.input_formats = input_formats
def to_python(self, value): def to_python(self, value):
# Try to coerce the value to unicode. value = value.strip()
unicode_value = force_text(value, strings_only=True) # Try to strptime against each input format.
if isinstance(unicode_value, str): for format in self.input_formats:
value = unicode_value.strip() try:
# If unicode, try to strptime against each input format. return self.strptime(value, format)
if isinstance(value, str): except (ValueError, TypeError):
for format in self.input_formats: continue
try:
return self.strptime(value, format)
except (ValueError, TypeError):
continue
raise ValidationError(self.error_messages['invalid'], code='invalid') raise ValidationError(self.error_messages['invalid'], code='invalid')
def strptime(self, value, format): def strptime(self, value, format):