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