Index: Lib/urllib/request.py =================================================================== --- Lib/urllib/request.py (revision 82895) +++ Lib/urllib/request.py (revision ) @@ -1591,13 +1591,13 @@ if proxy_passwd: import base64 - proxy_auth = base64.b64encode(proxy_passwd).strip() + proxy_auth = base64.b64encode(proxy_passwd.encode()).strip() else: proxy_auth = None if user_passwd: import base64 - auth = base64.b64encode(user_passwd).strip() + auth = base64.b64encode(user_passwd.encode()).strip() else: auth = None http_conn = connection_factory(host) Index: Lib/test/test_urllib.py =================================================================== --- Lib/test/test_urllib.py (revision 82983) +++ Lib/test/test_urllib.py (revision ) @@ -190,6 +190,13 @@ finally: self.unfakehttp() + def test_username_password(self): + self.fakehttp(b'Hello!') + try: + urlopen('http://username:password@google.com/index.html') + finally: + self.unfakehttp() + class urlretrieve_FileTests(unittest.TestCase): """Test urllib.urlretrieve() on local files"""