From 53b099f959636719525be988ee6e4a653f2d748f Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Mon, 5 Apr 2010 21:54:35 +0200 Subject: auth=b'Basic ' will throw a SyntaxError on 2.5 --HG-- branch : distribute extra : rebase_source : cbac0260bc300fc00ce3517ecd96d5bedc5cd896 --- setuptools/command/upload_docs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/upload_docs.py') diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index e961a0df..381ba1df 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -92,7 +92,7 @@ class upload_docs(upload): try: # base64 only works with bytes in Python 3. encoded_creds = base64.encodebytes(credentials.encode('utf8')) auth = b"Basic " - except AttributeError: + except (AttributeError, SyntaxError): encoded_creds = base64.encodestring(credentials) auth = "Basic " auth += encoded_creds.strip() -- cgit v1.2.1 From 4c4b93069581da0279ef1b037367592040a25532 Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Mon, 5 Apr 2010 22:18:39 +0200 Subject: proper fix to avoid a syntax error on 2.5 --HG-- branch : distribute extra : rebase_source : 320da069dcb5d4c3ffb94e6e4f0e78a1bef8a305 --- setuptools/command/upload_docs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/upload_docs.py') diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index 381ba1df..17686265 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -91,8 +91,8 @@ class upload_docs(upload): 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, SyntaxError): + auth = bytes("Basic ") + except AttributeError: encoded_creds = base64.encodestring(credentials) auth = "Basic " auth += encoded_creds.strip() -- cgit v1.2.1 From 58ec0860c3fef3a4c1a3da60b8340a21420724bd Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Mon, 5 Apr 2010 22:26:07 +0200 Subject: using a py3 marker instead of a try..except --HG-- branch : distribute extra : rebase_source : e3ccffb120f1fdaddfa0746c0a592d6fbaf0dcd1 --- setuptools/command/upload_docs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'setuptools/command/upload_docs.py') 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() -- cgit v1.2.1 From 6a6a261fa50522d77fba6d6345fb71ba9f00c311 Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Thu, 6 May 2010 18:10:32 +0200 Subject: make sure all tests passes on all python versions fixes #149 --HG-- branch : distribute extra : rebase_source : 6288f4fcf65083b9d4ffb0ea8b35af44e699b4d5 --- setuptools/command/upload_docs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setuptools/command/upload_docs.py') diff --git a/setuptools/command/upload_docs.py b/setuptools/command/upload_docs.py index ea2bad7e..213f7b58 100644 --- a/setuptools/command/upload_docs.py +++ b/setuptools/command/upload_docs.py @@ -16,7 +16,11 @@ import sys from distutils import log from distutils.errors import DistutilsOptionError -from distutils.command.upload import upload + +try: + from distutils.command.upload import upload +except ImportError: + from setuptools.command.upload import upload _IS_PYTHON3 = sys.version > '3' -- cgit v1.2.1