← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:avoid-private-urllib-request-functions into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:avoid-private-urllib-request-functions into launchpad:master.

Commit message:
Avoid importing private urllib.request names

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/420297

`urllib.request` defines an `__all__` list that doesn't include `parse_http_list` or `parse_keqv_list`, so we get import pedant warnings once we start importing these directly from `urllib.request` rather than via `six`.  Use the equivalent (and slightly simpler to use) `requests.utils.parse_dict_header` instead.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:avoid-private-urllib-request-functions into launchpad:master.
diff --git a/lib/lp/oci/model/ociregistryclient.py b/lib/lp/oci/model/ociregistryclient.py
index 30a99ad..e04a17a 100644
--- a/lib/lp/oci/model/ociregistryclient.py
+++ b/lib/lp/oci/model/ociregistryclient.py
@@ -23,11 +23,8 @@ from requests.exceptions import (
     ConnectionError,
     HTTPError,
     )
+from requests.utils import parse_dict_header
 from six.moves.urllib.parse import urlparse
-from six.moves.urllib.request import (
-    parse_http_list,
-    parse_keqv_list,
-    )
 from tenacity import (
     before_log,
     retry,
@@ -707,7 +704,7 @@ class BearerTokenRegistryClient(RegistryHTTPClient):
         parameters of the token GET request."""
         instructions = request.headers['Www-Authenticate']
         token_type, values = instructions.split(' ', 1)
-        dict_values = parse_keqv_list(parse_http_list(values))
+        dict_values = parse_dict_header(values)
         return token_type, dict_values
 
     def authenticate(self, last_failed_request):

Follow ups