From eca7db803f7c10ebce0a16e982351fbdd60c3321 Mon Sep 17 00:00:00 2001 From: "\"Brett Cannon ext:(%22)" Date: Sun, 17 Jan 2010 12:44:31 -0800 Subject: Change upload_docs so that its use of base64 does not fail under Python 3. While base64 accepts a string in Python 2, the module in Python 3 only works with bytes. Changed the code so that base64.encodebytes() is used, else catch the AttributeError and use base64.encodestring(). Not fully tested yet as there is another failure farther down under under Python 3. --HG-- branch : distribute extra : rebase_source : 37078c416d98ee7f6dff1715731ab3f0c186b6cf --- setuptools/command/upload_docs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'setuptools/command/upload_docs.py') diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index 29c62f2a..566a7268 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -75,8 +75,14 @@ class upload_docs(upload): 'content': (os.path.basename(filename), content), } # set up the authentication - auth = "Basic " + base64.encodestring( - self.username + ":" + self.password).strip() + credentials = self.username + ':' + self.password + try: # base64 only works with bytes in Python 3. + encoded_creds = base64.encodebytes(credentials.encode('utf8')) + auth = b"Basic" + except AttributeError: + encoded_creds = base64.encodestring(credentials) + auth = "Basic" + auth += encoded_creds.strip() # Build up the MIME payload for the POST data boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254' -- cgit v1.2.3