diff options
Diffstat (limited to 'django/utils/regex_helper.py')
-rw-r--r-- | django/utils/regex_helper.py | 15 |
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)) |