From 8b8da1946efc6327f8a9e8bb478cb10f05cb24b5 Mon Sep 17 00:00:00 2001 From: Ralph Bean Date: Wed, 25 Sep 2013 13:27:45 -0400 Subject: [PATCH 2/3] unbundle --- setup.py | 1 - test-requirements.txt | 2 ++ test/test_collections.py | 7 ++++++- test/test_connectionpool.py | 8 +++++++- test/test_fields.py | 3 ++- test/test_filepost.py | 2 +- urllib3/_collections.py | 2 +- urllib3/connectionpool.py | 12 ++++++++++-- urllib3/fields.py | 2 +- urllib3/filepost.py | 4 ++-- urllib3/response.py | 2 +- urllib3/util.py | 2 +- 12 files changed, 34 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index 392b885..82af89c 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,6 @@ setup(name='urllib3', url='http://urllib3.readthedocs.org/', license='MIT', packages=['urllib3', 'dummyserver', - 'urllib3.packages', 'urllib3.packages.ssl_match_hostname', 'urllib3.contrib', ], requires=requirements, diff --git a/test-requirements.txt b/test-requirements.txt index f7c3a50..0fea32c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,3 +2,5 @@ nose==1.3 mock==1.0.1 tornado==2.4.1 coverage==3.6 +six +backports.ssl_match_hostname diff --git a/test/test_collections.py b/test/test_collections.py index b44c58a..962b6fd 100644 --- a/test/test_collections.py +++ b/test/test_collections.py @@ -1,7 +1,12 @@ import unittest from urllib3._collections import RecentlyUsedContainer as Container -from urllib3.packages import six + +try: + import six +except ImportError: + from urllib3.packages import six + xrange = six.moves.xrange diff --git a/test/test_connectionpool.py b/test/test_connectionpool.py index ac1768e..c386798 100644 --- a/test/test_connectionpool.py +++ b/test/test_connectionpool.py @@ -6,7 +6,13 @@ from urllib3.connectionpool import ( HTTPConnectionPool, ) from urllib3.util import Timeout -from urllib3.packages.ssl_match_hostname import CertificateError +try: + # python3.2+ + from ssl import CertificateError +except ImportError: + # Older python where the backport from pypi is installed + from backports.ssl_match_hostname import CertificateError + from urllib3.exceptions import ( ClosedPoolError, EmptyPoolError, diff --git a/test/test_fields.py b/test/test_fields.py index 888c2d5..ddda1cf 100644 --- a/test/test_fields.py +++ b/test/test_fields.py @@ -1,7 +1,8 @@ import unittest from urllib3.fields import guess_content_type, RequestField -from urllib3.packages.six import b, u + +from six import b, u class TestRequestField(unittest.TestCase): diff --git a/test/test_filepost.py b/test/test_filepost.py index ca33d61..1b884c3 100644 --- a/test/test_filepost.py +++ b/test/test_filepost.py @@ -2,7 +2,7 @@ import unittest from urllib3.filepost import encode_multipart_formdata, iter_fields from urllib3.fields import RequestField -from urllib3.packages.six import b, u +from six import b, u BOUNDARY = '!! test boundary !!' diff --git a/urllib3/_collections.py b/urllib3/_collections.py index 282b8d5..9210312 100644 --- a/urllib3/_collections.py +++ b/urllib3/_collections.py @@ -10,7 +10,7 @@ from threading import RLock try: # Python 2.7+ from collections import OrderedDict except ImportError: - from .packages.ordered_dict import OrderedDict + from ordereddict import OrderedDict __all__ = ['RecentlyUsedContainer'] diff --git a/urllib3/connectionpool.py b/urllib3/connectionpool.py index 551b6fd..f2c1438 100644 --- a/urllib3/connectionpool.py +++ b/urllib3/connectionpool.py @@ -54,8 +54,16 @@ from .exceptions import ( ReadTimeoutError, ProxyError, ) -from .packages.ssl_match_hostname import CertificateError, match_hostname -from .packages import six + +try: + # python3.2+ + from ssl import match_hostname, CertificateError +except ImportError: + # Older python where the backport from pypi is installed + from backports.ssl_match_hostname import match_hostname, CertificateError + +import six + from .request import RequestMethods from .response import HTTPResponse from .util import ( diff --git a/urllib3/fields.py b/urllib3/fields.py index ed01765..7a33b95 100644 --- a/urllib3/fields.py +++ b/urllib3/fields.py @@ -7,7 +7,7 @@ import email.utils import mimetypes -from .packages import six +import six def guess_content_type(filename, default='application/octet-stream'): diff --git a/urllib3/filepost.py b/urllib3/filepost.py index 4575582..bc4a161 100644 --- a/urllib3/filepost.py +++ b/urllib3/filepost.py @@ -10,8 +10,8 @@ import mimetypes from uuid import uuid4 from io import BytesIO -from .packages import six -from .packages.six import b +import six +from six import b from .fields import RequestField writer = codecs.lookup('utf-8')[3] diff --git a/urllib3/response.py b/urllib3/response.py index 4efff5a..32b2b3e 100644 --- a/urllib3/response.py +++ b/urllib3/response.py @@ -10,7 +10,7 @@ import zlib import io from .exceptions import DecodeError -from .packages.six import string_types as basestring, binary_type +from six import string_types as basestring, binary_type from .util import is_fp_closed diff --git a/urllib3/util.py b/urllib3/util.py index 266c9ed..49de5fb 100644 --- a/urllib3/util.py +++ b/urllib3/util.py @@ -32,7 +32,7 @@ try: # Test for SSL features except ImportError: pass -from .packages import six +import six from .exceptions import LocationParseError, SSLError, TimeoutStateError -- 1.8.3.1