From c69e4bc69166b2d752b437a651dfa91f8b53ecfd Mon Sep 17 00:00:00 2001 From: Дилян Палаузов Date: Mon, 6 Nov 2017 10:23:29 -0500 Subject: Fixed #28769 -- Replaced 'x if x else y' with 'x or y'. --- django/utils/dateparse.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'django/utils/dateparse.py') diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py index ffb37afcdf..e0e5e244c7 100644 --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -131,9 +131,11 @@ def parse_duration(value): Also supports ISO 8601 representation and PostgreSQL's day-time interval format. """ - match = standard_duration_re.match(value) - if not match: - match = iso8601_duration_re.match(value) or postgres_interval_re.match(value) + match = ( + standard_duration_re.match(value) or + iso8601_duration_re.match(value) or + postgres_interval_re.match(value) + ) if match: kw = match.groupdict() days = datetime.timedelta(float(kw.pop('days', 0) or 0)) -- cgit v1.3