Commits

"Bre...@python.org>"  committed 67da0cf

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.

  • Participants
  • Parent commits 609acb9
  • Branches 0.6-maintenance

Comments (0)

Files changed (1)

File setuptools/command/upload_docs.py

             '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'