summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2017-05-18 14:35:54 (GMT)
committerRaymond Hettinger <rhettinger@users.noreply.github.com>2017-05-18 14:35:54 (GMT)
commit3972628de3d569c88451a2a176a1c94d8822b8a6 (patch)
tree30627d132c42fb65f96c3d9e209b317f68d175ed /Lib/urllib
parent906f5330b9c9a74cad1cf27fddaf77e99dff9edd (diff)
downloadcpython-3972628de3d569c88451a2a176a1c94d8822b8a6.zip
cpython-3972628de3d569c88451a2a176a1c94d8822b8a6.tar.gz
cpython-3972628de3d569c88451a2a176a1c94d8822b8a6.tar.bz2
bpo-30296 Remove unnecessary tuples, lists, sets, and dicts (#1489)
* Replaced list(<generator expression>) with list comprehension * Replaced dict(<generator expression>) with dict comprehension * Replaced set(<list literal>) with set literal * Replaced builtin func(<list comprehension>) with func(<generator expression>) when supported (e.g. any(), all(), tuple(), min(), & max())
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/request.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 3f8dcfb..a192d52 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -683,8 +683,8 @@ class HTTPRedirectHandler(BaseHandler):
newurl = newurl.replace(' ', '%20')
CONTENT_HEADERS = ("content-length", "content-type")
- newheaders = dict((k, v) for k, v in req.headers.items()
- if k.lower() not in CONTENT_HEADERS)
+ newheaders = {k: v for k, v in req.headers.items()
+ if k.lower() not in CONTENT_HEADERS}
return Request(newurl,
headers=newheaders,
origin_req_host=req.origin_req_host,
@@ -845,7 +845,7 @@ class HTTPPasswordMgr:
self.passwd[realm] = {}
for default_port in True, False:
reduced_uri = tuple(
- [self.reduce_uri(u, default_port) for u in uri])
+ self.reduce_uri(u, default_port) for u in uri)
self.passwd[realm][reduced_uri] = (user, passwd)
def find_user_password(self, realm, authuri):
@@ -1286,8 +1286,7 @@ class AbstractHTTPHandler(BaseHandler):
h.set_debuglevel(self._debuglevel)
headers = dict(req.unredirected_hdrs)
- headers.update(dict((k, v) for k, v in req.headers.items()
- if k not in headers))
+ headers.update((k, v) for k, v in req.headers.items() if k not in headers)
# TODO(jhylton): Should this be redesigned to handle
# persistent connections?
@@ -1299,7 +1298,7 @@ class AbstractHTTPHandler(BaseHandler):
# So make sure the connection gets closed after the (only)
# request.
headers["Connection"] = "close"
- headers = dict((name.title(), val) for name, val in headers.items())
+ headers = {name.title(): val for name, val in headers.items()}
if req._tunnel_host:
tunnel_headers = {}