summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorДилян Палаузов <Dilyan.Palauzov@db.com>2018-01-12 09:05:16 -0500
committerTim Graham <timograham@gmail.com>2018-01-12 12:44:50 -0500
commita38ae914d89809aed6d79337b74a8b31b6d3849a (patch)
tree42a8465e37fc02b70d8d3f876d23947acb1a2455 /django/utils
parent4bcec02368b7e5466f64dc17286689b16613c94b (diff)
Fixed #28996 -- Simplified some boolean constructs and removed trivial continue statements.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/cache.py5
-rw-r--r--django/utils/datastructures.py6
-rw-r--r--django/utils/regex_helper.py3
3 files changed, 5 insertions, 9 deletions
diff --git a/django/utils/cache.py b/django/utils/cache.py
index cb49806ee9..86234f7aed 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -376,9 +376,8 @@ def learn_cache_key(request, response, cache_timeout=None, key_prefix=None, cach
headerlist = []
for header in cc_delim_re.split(response['Vary']):
header = header.upper().replace('-', '_')
- if header == 'ACCEPT_LANGUAGE' and is_accept_language_redundant:
- continue
- headerlist.append('HTTP_' + header)
+ if header != 'ACCEPT_LANGUAGE' or not is_accept_language_redundant:
+ headerlist.append('HTTP_' + header)
headerlist.sort()
cache.set(cache_key, headerlist, cache_timeout)
return _generate_cache_key(request, request.method, headerlist, key_prefix)
diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py
index 127c6dc774..2f02a2c74d 100644
--- a/django/utils/datastructures.py
+++ b/django/utils/datastructures.py
@@ -275,11 +275,9 @@ class DictWrapper(dict):
present). If the prefix is present, pass the value through self.func
before returning, otherwise return the raw value.
"""
- if key.startswith(self.prefix):
- use_func = True
+ use_func = key.startswith(self.prefix)
+ if use_func:
key = key[len(self.prefix):]
- else:
- use_func = False
value = super().__getitem__(key)
if use_func:
return self.func(value)
diff --git a/django/utils/regex_helper.py b/django/utils/regex_helper.py
index b06acb0191..8d55a79272 100644
--- a/django/utils/regex_helper.py
+++ b/django/utils/regex_helper.py
@@ -176,8 +176,7 @@ def normalize(pattern):
if consume_next:
ch, escaped = next(pattern_iter)
- else:
- consume_next = True
+ consume_next = True
except StopIteration:
pass
except NotImplementedError: