summaryrefslogtreecommitdiff
path: root/django/utils/regex_helper.py
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-12-27 15:59:13 -0500
committerGitHub <noreply@github.com>2016-12-27 15:59:13 -0500
commit51cde873d9fc8e4540f4efecbd39cfe8e770be38 (patch)
tree6ceaf250f599a9e108f6b75b74a8f5b4e06bd08b /django/utils/regex_helper.py
parent544b2ef29f0f2577912f88cf746ae0ca5877b5f8 (diff)
downloaddjango-51cde873d9fc8e4540f4efecbd39cfe8e770be38.tar.gz
Fixed #27648 -- Deprecated (iLmsu) regex groups in url() patterns.
Diffstat (limited to 'django/utils/regex_helper.py')
-rw-r--r--django/utils/regex_helper.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/django/utils/regex_helper.py b/django/utils/regex_helper.py
index 622d822759..d046b71d96 100644
--- a/django/utils/regex_helper.py
+++ b/django/utils/regex_helper.py
@@ -7,7 +7,10 @@ should be good enough for a large class of URLS, however.
"""
from __future__ import unicode_literals
+import warnings
+
from django.utils import six
+from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.six.moves import zip
# Mapping of an escape character to a representative of that class. So, e.g.,
@@ -59,9 +62,7 @@ def normalize(pattern):
(3) Select the first (essentially an arbitrary) element from any character
class. Select an arbitrary character for any unordered class (e.g. '.'
or '\w') in the pattern.
- (4) Ignore comments, look-ahead and look-behind assertions, and any of the
- reg-exp flags that won't change what we construct ("iLmsu"). "(?x)" is
- an error, however.
+ (4) Ignore look-ahead and look-behind assertions.
(5) Raise an error on any disjunctive ('|') constructs.
Django's URLs for forward resolving are either all positional arguments or
@@ -128,10 +129,16 @@ def normalize(pattern):
walk_to_end(ch, pattern_iter)
else:
ch, escaped = next(pattern_iter)
- if ch in "iLmsu#!=<":
+ if ch in '!=<':
# All of these are ignorable. Walk to the end of the
# group.
walk_to_end(ch, pattern_iter)
+ elif ch in 'iLmsu#':
+ warnings.warn(
+ 'Using (?%s) in url() patterns is deprecated.' % ch,
+ RemovedInDjango21Warning
+ )
+ walk_to_end(ch, pattern_iter)
elif ch == ':':
# Non-capturing group
non_capturing_groups.append(len(result))