From 8119b679eb85cdc0ae3d321e54d06dd0200a1e82 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 16 Sep 2016 12:15:00 -0400 Subject: Refs #27025 -- Fixed "invalid escape sequence" warnings in Python 3.6. http://bugs.python.org/issue27364 --- django/utils/html.py | 2 +- django/utils/regex_helper.py | 4 ++-- django/utils/text.py | 8 ++++---- django/utils/translation/__init__.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'django/utils') diff --git a/django/utils/html.py b/django/utils/html.py index a5cb56ec9e..84379caa9c 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -36,7 +36,7 @@ simple_email_re = re.compile(r'^\S+@\S+\.\S+$') link_target_attribute_re = re.compile(r'(]*?)target=[^\s>]+') html_gunk_re = re.compile( r'(?:
|<\/i>|<\/b>|<\/em>|<\/strong>|' - '<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) + r'<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) hard_coded_bullets_re = re.compile( r'((?:

(?:%s).*?[a-zA-Z].*?

\s*)+)' % '|'.join(re.escape(x) for x in DOTS), re.DOTALL ) diff --git a/django/utils/regex_helper.py b/django/utils/regex_helper.py index 4a697b2920..622d822759 100644 --- a/django/utils/regex_helper.py +++ b/django/utils/regex_helper.py @@ -48,7 +48,7 @@ class NonCapture(list): def normalize(pattern): - """ + r""" Given a reg-exp pattern, normalizes it to an iterable of forms that suffice for reverse matching. This does the following: @@ -203,7 +203,7 @@ def normalize(pattern): def next_char(input_iter): - """ + r""" An iterator that yields the next character from "pattern_iter", respecting escape sequences. An escaped character is replaced by a representative of its class (e.g. \w -> "x"). If the escaped character is one that is diff --git a/django/utils/text.py b/django/utils/text.py index 3b8fc581bf..a77f27eed7 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -423,11 +423,11 @@ def slugify(value, allow_unicode=False): value = force_text(value) if allow_unicode: value = unicodedata.normalize('NFKC', value) - value = re.sub('[^\w\s-]', '', value, flags=re.U).strip().lower() - return mark_safe(re.sub('[-\s]+', '-', value, flags=re.U)) + value = re.sub(r'[^\w\s-]', '', value, flags=re.U).strip().lower() + return mark_safe(re.sub(r'[-\s]+', '-', value, flags=re.U)) value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii') - value = re.sub('[^\w\s-]', '', value).strip().lower() - return mark_safe(re.sub('[-\s]+', '-', value)) + value = re.sub(r'[^\w\s-]', '', value).strip().lower() + return mark_safe(re.sub(r'[-\s]+', '-', value)) def camel_case_to_spaces(value): diff --git a/django/utils/translation/__init__.py b/django/utils/translation/__init__.py index 9154ceeb7b..a5975b005c 100644 --- a/django/utils/translation/__init__.py +++ b/django/utils/translation/__init__.py @@ -255,7 +255,7 @@ def get_language_info(lang_code): info['name_translated'] = ugettext_lazy(info['name']) return info -trim_whitespace_re = re.compile('\s*\n\s*') +trim_whitespace_re = re.compile(r'\s*\n\s*') def trim_whitespace(s): -- cgit v1.3