diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index b4ee064ed..428669349 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -441,7 +441,8 @@ class HyperlinkAvailabilityCheckWorker(Thread): return 'broken', error_message, 0 # Success; clear rate limits for the origin - self.rate_limits.pop(urlsplit(req_url).netloc, None) + netloc = urlsplit(req_url).netloc + self.rate_limits.pop(netloc, None) if ((response_url.rstrip('/') == req_url.rstrip('/')) or _allowed_redirect(req_url, response_url, @@ -503,8 +504,7 @@ def _get_request_headers( for u in candidates: if u in request_headers: - headers = {**DEFAULT_REQUEST_HEADERS, **request_headers[u]} - return headers + return {**DEFAULT_REQUEST_HEADERS, **request_headers[u]} return {}