diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-05-13 20:29:07 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-05-13 20:29:07 -0700 |
commit | 28213c0fb01e4c0db62c7fd4d6ffcc1ff5383fa5 (patch) | |
tree | cc8a0b6d0d334f97c25130cbc464c23706958724 | |
parent | a4e23d4b6c4631a8622e72b2c5ab903533615b6b (diff) | |
download | portage-28213c0fb01e4c0db62c7fd4d6ffcc1ff5383fa5.tar.gz portage-28213c0fb01e4c0db62c7fd4d6ffcc1ff5383fa5.tar.bz2 portage-28213c0fb01e4c0db62c7fd4d6ffcc1ff5383fa5.zip |
getbinpkg: fix base64 usage for python3
-rw-r--r-- | pym/portage/getbinpkg.py | 13 |
1 files 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"" ), } |