summaryrefslogtreecommitdiff
path: root/django/utils/datetime_safe.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-10-26 16:42:32 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-10-29 09:22:26 +0100
commite3d0b4d5501c6d0bc39f035e4345e5bdfde12e41 (patch)
treea8ddbafdf4a38a87df6f65fc4d02dba08c725096 /django/utils/datetime_safe.py
parent39a34d4bf94bc8325119bc23b64f3a041a85dd2d (diff)
Fixed #30899 -- Lazily compiled import time regular expressions.
Diffstat (limited to 'django/utils/datetime_safe.py')
-rw-r--r--django/utils/datetime_safe.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/django/utils/datetime_safe.py b/django/utils/datetime_safe.py
index 7eaa5c21ce..ade2dca610 100644
--- a/django/utils/datetime_safe.py
+++ b/django/utils/datetime_safe.py
@@ -7,12 +7,13 @@
# >>> datetime_safe.date(10, 8, 2).strftime("%Y/%m/%d was a %A")
# '0010/08/02 was a Monday'
-import re
import time as ttime
from datetime import (
date as real_date, datetime as real_datetime, time as real_time,
)
+from django.utils.regex_helper import _lazy_re_compile
+
class date(real_date):
def strftime(self, fmt):
@@ -54,7 +55,7 @@ def new_datetime(d):
# This library does not support strftime's "%s" or "%y" format strings.
# Allowed if there's an even number of "%"s because they are escaped.
-_illegal_formatting = re.compile(r"((^|[^%])(%%)*%[sy])")
+_illegal_formatting = _lazy_re_compile(r"((^|[^%])(%%)*%[sy])")
def _findall(text, substr):