Commit 58ec0860 authored by Tarek Ziade's avatar Tarek Ziade

using a py3 marker instead of a try..except

--HG--
branch : distribute
extra : rebase_source : e3ccffb120f1fdaddfa0746c0a592d6fbaf0dcd1
parent 4c4b9306
......@@ -12,11 +12,14 @@ import httplib
import base64
import urlparse
import tempfile
import sys
from distutils import log
from distutils.errors import DistutilsOptionError
from distutils.command.upload import upload
_IS_PYTHON3 = sys.version > '3'
try:
bytes
except NameError:
......@@ -89,10 +92,10 @@ class upload_docs(upload):
}
# set up the authentication
credentials = self.username + ':' + self.password
try: # base64 only works with bytes in Python 3.
if _IS_PYTHON3: # base64 only works with bytes in Python 3.
encoded_creds = base64.encodebytes(credentials.encode('utf8'))
auth = bytes("Basic ")
except AttributeError:
else:
encoded_creds = base64.encodestring(credentials)
auth = "Basic "
auth += encoded_creds.strip()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment