summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2011-10-19 18:48:01 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2011-10-19 18:48:01 (GMT)
commit34d38dce11cecde871c26cdf344ab5169c2cb9db (patch)
treec2990cccd48dc6ddb4cf6d4bff722b35f6828175 /Lib/urllib
parent202a3c422b400ee46c61cb9b22ca8ec4b80dfdfd (diff)
downloadcpython-34d38dce11cecde871c26cdf344ab5169c2cb9db.zip
cpython-34d38dce11cecde871c26cdf344ab5169c2cb9db.tar.gz
cpython-34d38dce11cecde871c26cdf344ab5169c2cb9db.tar.bz2
urllib.request - syntax changes enhancing readability. By Éric Araujo
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/request.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index d3b5c29..8ea058f 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -552,12 +552,11 @@ class HTTPRedirectHandler(BaseHandler):
# For security reasons we don't allow redirection to anything other
# than http, https or ftp.
- if not urlparts.scheme in ('http', 'https', 'ftp'):
- raise HTTPError(newurl, code,
- msg +
- " - Redirection to url '%s' is not allowed" %
- newurl,
- headers, fp)
+ if urlparts.scheme not in ('http', 'https', 'ftp'):
+ raise HTTPError(
+ newurl, code,
+ "%s - Redirection to url '%s' is not allowed" % (msg, newurl),
+ headers, fp)
if not urlparts.path:
urlparts = list(urlparts)
@@ -722,7 +721,7 @@ class HTTPPasswordMgr:
# uri could be a single URI or a sequence
if isinstance(uri, str):
uri = [uri]
- if not realm in self.passwd:
+ if realm not in self.passwd:
self.passwd[realm] = {}
for default_port in True, False:
reduced_uri = tuple(
@@ -1823,7 +1822,7 @@ class URLopener:
del self.ftpcache[k]
v.close()
try:
- if not key in self.ftpcache:
+ if key not in self.ftpcache:
self.ftpcache[key] = \
ftpwrapper(user, passwd, host, port, dirs)
if not file: type = 'D'
@@ -1938,7 +1937,7 @@ class FancyURLopener(URLopener):
# We are using newer HTTPError with older redirect_internal method
# This older method will get deprecated in 3.3
- if not urlparts.scheme in ('http', 'https', 'ftp'):
+ if urlparts.scheme not in ('http', 'https', 'ftp'):
raise HTTPError(newurl, errcode,
errmsg +
" Redirection to url '%s' is not allowed." % newurl,
@@ -1965,7 +1964,7 @@ class FancyURLopener(URLopener):
retry=False):
"""Error 401 -- authentication required.
This function supports Basic authentication only."""
- if not 'www-authenticate' in headers:
+ if 'www-authenticate' not in headers:
URLopener.http_error_default(self, url, fp,
errcode, errmsg, headers)
stuff = headers['www-authenticate']
@@ -1991,7 +1990,7 @@ class FancyURLopener(URLopener):
retry=False):
"""Error 407 -- proxy authentication required.
This function supports Basic authentication only."""
- if not 'proxy-authenticate' in headers:
+ if 'proxy-authenticate' not in headers:
URLopener.http_error_default(self, url, fp,
errcode, errmsg, headers)
stuff = headers['proxy-authenticate']