summaryrefslogtreecommitdiffstats
path: root/Lib/urllib.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-02-01 23:36:55 (GMT)
committerGuido van Rossum <guido@python.org>2000-02-01 23:36:55 (GMT)
commit3c8baedaf8c69bd92f06a7de5f16cde19a9beb55 (patch)
treec1bdd1d37789a0d18167c8c14c17f8e322882473 /Lib/urllib.py
parenta664dbbff8ad22d0eb4ec48461d3d9a50c5fb693 (diff)
downloadcpython-3c8baedaf8c69bd92f06a7de5f16cde19a9beb55.zip
cpython-3c8baedaf8c69bd92f06a7de5f16cde19a9beb55.tar.gz
cpython-3c8baedaf8c69bd92f06a7de5f16cde19a9beb55.tar.bz2
Sjoerd Mullender writes:
Fixed a TypeError: not enough arguments; expected 4, got 3. When authentication is needed, the default http_error_401 method calls retry_http_basic_auth. The default version of that method expected a data argument which wasn't provided, so now we provide the argument if it was given and we also made the data argument optional. Also changed other calls where data was optional to not pass data if it was not passed to the calling method (in line with other similar occurances).
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r--Lib/urllib.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index ffbab22..dbe3bee 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -499,7 +499,10 @@ class FancyURLopener(URLopener):
fp.close()
# In case the server sent a relative URL, join with original:
newurl = basejoin("http:" + url, newurl)
- return self.open(newurl, data)
+ if data is None:
+ return self.open(newurl)
+ else:
+ return self.open(newurl, data)
# Error 301 -- also relocated (permanently)
http_error_301 = http_error_302
@@ -517,9 +520,12 @@ class FancyURLopener(URLopener):
scheme, realm = match.groups()
if string.lower(scheme) == 'basic':
name = 'retry_' + self.type + '_basic_auth'
- return getattr(self,name)(url, realm)
+ if data is None:
+ return getattr(self,name)(url, realm)
+ else:
+ return getattr(self,name)(url, realm, data)
- def retry_http_basic_auth(self, url, realm, data):
+ def retry_http_basic_auth(self, url, realm, data=None):
host, selector = splithost(url)
i = string.find(host, '@') + 1
host = host[i:]
@@ -527,9 +533,12 @@ class FancyURLopener(URLopener):
if not (user or passwd): return None
host = user + ':' + passwd + '@' + host
newurl = 'http://' + host + selector
- return self.open(newurl, data)
+ if data is None:
+ return self.open(newurl)
+ else:
+ return self.open(newurl, data)
- def retry_https_basic_auth(self, url, realm):
+ def retry_https_basic_auth(self, url, realm, data=None):
host, selector = splithost(url)
i = string.find(host, '@') + 1
host = host[i:]