diff options
author | Tarek Ziade <tarek@ziade.org> | 2010-04-05 22:26:07 +0200 |
---|---|---|
committer | Tarek Ziade <tarek@ziade.org> | 2010-04-05 22:26:07 +0200 |
commit | 58ec0860c3fef3a4c1a3da60b8340a21420724bd (patch) | |
tree | f4289af63735542257381e20533242854badc964 /setuptools/command/upload_docs.py | |
parent | 4c4b93069581da0279ef1b037367592040a25532 (diff) | |
download | python-setuptools-git-58ec0860c3fef3a4c1a3da60b8340a21420724bd.tar.gz |
using a py3 marker instead of a try..except
--HG--
branch : distribute
extra : rebase_source : e3ccffb120f1fdaddfa0746c0a592d6fbaf0dcd1
Diffstat (limited to 'setuptools/command/upload_docs.py')
-rw-r--r-- | setuptools/command/upload_docs.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index 17686265..ea2bad7e 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -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() |