From: Zac Medico Date: Mon, 14 May 2012 03:29:07 +0000 (-0700) Subject: getbinpkg: fix base64 usage for python3 X-Git-Tag: v2.2.0_alpha105~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=28213c0fb01e4c0db62c7fd4d6ffcc1ff5383fa5;p=portage.git getbinpkg: fix base64 usage for python3 --- diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index 579a46f9b..7dec20a44 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -158,11 +158,16 @@ def create_conn(baseurl,conn=None): http_headers = {} http_params = {} if username and password: + try: + encodebytes = base64.encodebytes + except AttributeError: + # Python 2 + encodebytes = base64.encodestring http_headers = { - "Authorization": "Basic %s" % - base64.encodestring("%s:%s" % (username, password)).replace( - "\012", - "" + b"Authorization": "Basic %s" % \ + encodebytes(_unicode_encode("%s:%s" % (username, password))).replace( + b"\012", + b"" ), }