diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2019-10-26 16:42:32 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-29 09:22:26 +0100 |
| commit | e3d0b4d5501c6d0bc39f035e4345e5bdfde12e41 (patch) | |
| tree | a8ddbafdf4a38a87df6f65fc4d02dba08c725096 /django/utils/dateparse.py | |
| parent | 39a34d4bf94bc8325119bc23b64f3a041a85dd2d (diff) | |
Fixed #30899 -- Lazily compiled import time regular expressions.
Diffstat (limited to 'django/utils/dateparse.py')
| -rw-r--r-- | django/utils/dateparse.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py index f90d952581..d142e161b6 100644 --- a/django/utils/dateparse.py +++ b/django/utils/dateparse.py @@ -6,27 +6,27 @@ # - The date/datetime/time constructors produce friendlier error messages. import datetime -import re +from django.utils.regex_helper import _lazy_re_compile from django.utils.timezone import get_fixed_timezone, utc -date_re = re.compile( +date_re = _lazy_re_compile( r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})$' ) -time_re = re.compile( +time_re = _lazy_re_compile( r'(?P<hour>\d{1,2}):(?P<minute>\d{1,2})' r'(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?' ) -datetime_re = re.compile( +datetime_re = _lazy_re_compile( r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})' r'[T ](?P<hour>\d{1,2}):(?P<minute>\d{1,2})' r'(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?' r'(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$' ) -standard_duration_re = re.compile( +standard_duration_re = _lazy_re_compile( r'^' r'(?:(?P<days>-?\d+) (days?, )?)?' r'(?P<sign>-?)' @@ -39,7 +39,7 @@ standard_duration_re = re.compile( # Support the sections of ISO 8601 date representation that are accepted by # timedelta -iso8601_duration_re = re.compile( +iso8601_duration_re = _lazy_re_compile( r'^(?P<sign>[-+]?)' r'P' r'(?:(?P<days>\d+(.\d+)?)D)?' @@ -54,7 +54,7 @@ iso8601_duration_re = re.compile( # Support PostgreSQL's day-time interval format, e.g. "3 days 04:05:06". The # year-month and mixed intervals cannot be converted to a timedelta and thus # aren't accepted. -postgres_interval_re = re.compile( +postgres_interval_re = _lazy_re_compile( r'^' r'(?:(?P<days>-?\d+) (days? ?))?' r'(?:(?P<sign>[-+])?' |
