From 28213c0fb01e4c0db62c7fd4d6ffcc1ff5383fa5 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 13 May 2012 20:29:07 -0700 Subject: [PATCH] getbinpkg: fix base64 usage for python3 --- pym/portage/getbinpkg.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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"" ), } -- 2.26.2