Allow TimePeriod for time_period_str_unit (#815)

This commit is contained in:
Otto Winter 2019-10-31 20:09:57 +01:00 committed by GitHub
parent 742c21506c
commit 864c5d8908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -461,6 +461,8 @@ def time_period_str_unit(value):
if isinstance(value, int):
raise Invalid("Don't know what '{0}' means as it has no time *unit*! Did you mean "
"'{0}s'?".format(value))
if isinstance(value, TimePeriod):
value = str(value)
if not isinstance(value, string_types):
raise Invalid("Expected string for time period with unit.")