diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-05-03 04:39:38 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-05-03 04:39:38 (GMT) |
commit | 5209857f8ef14876e03a3d7445bdad9b8de51faf (patch) | |
tree | 8e0393d0d42d9334b17295b531cc70ea263a9dae /Lib/urllib2.py | |
parent | 8cb02b6000c66478406c12270a9f86e39fd20305 (diff) | |
download | cpython-5209857f8ef14876e03a3d7445bdad9b8de51faf.zip cpython-5209857f8ef14876e03a3d7445bdad9b8de51faf.tar.gz cpython-5209857f8ef14876e03a3d7445bdad9b8de51faf.tar.bz2 |
Removed implicit convertions of str object to bytes from base64.
This also exposed some bugs in urlib2 and email.base64mime, which I
tried my best to fix. However, someone will probably have to double
check.
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r-- | Lib/urllib2.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 1458826..76035a3 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -682,7 +682,7 @@ class ProxyHandler(BaseHandler): proxy_type = orig_type if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) - creds = str(base64.b64encode(user_pass)).strip() + creds = base64.b64encode(user_pass.encode()).decode("ascii") req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) @@ -808,7 +808,7 @@ class AbstractBasicAuthHandler: user, pw = self.passwd.find_user_password(realm, host) if pw is not None: raw = "%s:%s" % (user, pw) - auth = 'Basic %s' % base64.b64encode(raw).strip().decode() + auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii") if req.headers.get(self.auth_header, None) == auth: return None req.add_header(self.auth_header, auth) |