summaryrefslogtreecommitdiff
path: root/django/utils/http.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2020-05-10 13:03:39 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-11 12:01:28 +0200
commitd6aff369ad33457ae2355b5b210faf1c4890ff35 (patch)
tree4c9d43311078bd81098e8a9fe9ff89fe007e921e /django/utils/http.py
parent23f6fbdd93cd668740e3a1cd6d8c8259f380c0fe (diff)
Refs #30116 -- Simplified regex match group access with Match.__getitem__().
The method has been available since Python 3.6. The shorter syntax is also marginally faster.
Diffstat (limited to 'django/utils/http.py')
-rw-r--r--django/utils/http.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/django/utils/http.py b/django/utils/http.py
index 709ce60e1f..c1005458e7 100644
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -175,7 +175,7 @@ def parse_http_date(date):
else:
raise ValueError("%r is not in a valid HTTP date format" % date)
try:
- year = int(m.group('year'))
+ year = int(m['year'])
if year < 100:
current_year = datetime.datetime.utcnow().year
current_century = current_year - (current_year % 100)
@@ -185,11 +185,11 @@ def parse_http_date(date):
year += current_century - 100
else:
year += current_century
- month = MONTHS.index(m.group('mon').lower()) + 1
- day = int(m.group('day'))
- hour = int(m.group('hour'))
- min = int(m.group('min'))
- sec = int(m.group('sec'))
+ month = MONTHS.index(m['mon'].lower()) + 1
+ day = int(m['day'])
+ hour = int(m['hour'])
+ min = int(m['min'])
+ sec = int(m['sec'])
result = datetime.datetime(year, month, day, hour, min, sec)
return calendar.timegm(result.utctimetuple())
except Exception as exc:
@@ -266,7 +266,7 @@ def parse_etags(etag_str):
else:
# Parse each ETag individually, and return any that are valid.
etag_matches = (ETAG_MATCH.match(etag.strip()) for etag in etag_str.split(','))
- return [match.group(1) for match in etag_matches if match]
+ return [match[1] for match in etag_matches if match]
def quote_etag(etag_str):