diff options
author | "Brett Cannon ext:(%22) <brett@python.org> | 2010-01-17 12:44:31 -0800 |
---|---|---|
committer | "Brett Cannon ext:(%22) <brett@python.org> | 2010-01-17 12:44:31 -0800 |
commit | eca7db803f7c10ebce0a16e982351fbdd60c3321 (patch) | |
tree | 47d21f502eb01da459503e72afa193ba08c55a81 /setuptools/command/upload_docs.py | |
parent | 3b04385b26f5921cc23593497b2c5a2dc596c417 (diff) | |
download | external_python_setuptools-eca7db803f7c10ebce0a16e982351fbdd60c3321.tar.gz external_python_setuptools-eca7db803f7c10ebce0a16e982351fbdd60c3321.tar.bz2 external_python_setuptools-eca7db803f7c10ebce0a16e982351fbdd60c3321.zip |
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
Diffstat (limited to 'setuptools/command/upload_docs.py')
-rw-r--r-- | setuptools/command/upload_docs.py | 10 |
1 files changed, 8 insertions, 2 deletions
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' |