Commits

Tarek Ziadé  committed b4b5fa5

using a py3 marker instead of a try..except

  • Participants
  • Parent commits acc3601
  • Branches 0.6-maintenance

Comments (0)

Files changed (1)

File setuptools/command/upload_docs.py

 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:
         }
         # 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()