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.
This commit is contained in:
Alexandre Vassalotti 2008-05-03 04:39:38 +00:00
parent 8cb02b6000
commit 5209857f8e
4 changed files with 42 additions and 16 deletions

View file

@ -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)