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