diff options
author | Hugo van Kemenade <hugovk@users.noreply.github.com> | 2019-08-26 04:00:07 +0300 |
---|---|---|
committer | Seth Michael Larson <sethmichaellarson@gmail.com> | 2019-08-25 20:00:07 -0500 |
commit | ae7f8bbb57e74ffdb327c5e510963a886fa4ed8b (patch) | |
tree | 5bdb0d3e775b4966637968f4336fdaa320e3a0d9 | |
parent | 6a626be4ff623c25270e20db9002705bf4504e4e (diff) | |
download | urllib3-ae7f8bbb57e74ffdb327c5e510963a886fa4ed8b.tar.gz |
Fix for Python 4 (#1669)
-rw-r--r-- | src/urllib3/connection.py | 2 | ||||
-rw-r--r-- | src/urllib3/fields.py | 4 | ||||
-rw-r--r-- | src/urllib3/filepost.py | 2 | ||||
-rw-r--r-- | src/urllib3/util/ssl_.py | 2 | ||||
-rw-r--r-- | test/__init__.py | 4 | ||||
-rw-r--r-- | test/appengine/conftest.py | 2 | ||||
-rw-r--r-- | test/test_collections.py | 2 |
7 files changed, 9 insertions, 9 deletions
diff --git a/src/urllib3/connection.py b/src/urllib3/connection.py index 86b9198a..3eeb1af5 100644 --- a/src/urllib3/connection.py +++ b/src/urllib3/connection.py @@ -99,7 +99,7 @@ class HTTPConnection(_HTTPConnection, object): is_verified = False def __init__(self, *args, **kw): - if six.PY3: + if not six.PY2: kw.pop("strict", None) # Pre-set source_address. diff --git a/src/urllib3/fields.py b/src/urllib3/fields.py index 534436f7..8715b220 100644 --- a/src/urllib3/fields.py +++ b/src/urllib3/fields.py @@ -47,7 +47,7 @@ def format_header_param_rfc2231(name, value): else: return result - if not six.PY3: # Python 2: + if six.PY2: # Python 2: value = value.encode("utf-8") # encode_rfc2231 accepts an encoded string and returns an ascii-encoded @@ -55,7 +55,7 @@ def format_header_param_rfc2231(name, value): value = email.utils.encode_rfc2231(value, "utf-8") value = "%s*=%s" % (name, value) - if not six.PY3: # Python 2: + if six.PY2: # Python 2: value = value.decode("utf-8") return value diff --git a/src/urllib3/filepost.py b/src/urllib3/filepost.py index 459e7904..b7b00992 100644 --- a/src/urllib3/filepost.py +++ b/src/urllib3/filepost.py @@ -17,7 +17,7 @@ def choose_boundary(): Our embarrassingly-simple replacement for mimetools.choose_boundary. """ boundary = binascii.hexlify(os.urandom(16)) - if six.PY3: + if not six.PY2: boundary = boundary.decode("ascii") return boundary diff --git a/src/urllib3/util/ssl_.py b/src/urllib3/util/ssl_.py index a21fd91a..4fe41207 100644 --- a/src/urllib3/util/ssl_.py +++ b/src/urllib3/util/ssl_.py @@ -385,7 +385,7 @@ def is_ipaddress(hostname): :param str hostname: Hostname to examine. :return: True if the hostname is an IP address, False otherwise. """ - if six.PY3 and isinstance(hostname, bytes): + if not six.PY2 and isinstance(hostname, bytes): # IDN A-label bytes are ASCII compatible. hostname = hostname.decode("ascii") return bool(IPV4_RE.match(hostname) or BRACELESS_IPV6_ADDRZ_RE.match(hostname)) diff --git a/test/__init__.py b/test/__init__.py index 31720c59..c89d0126 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -62,7 +62,7 @@ def onlyPy2(test): @functools.wraps(test) def wrapper(*args, **kwargs): msg = "{name} requires Python 2.x to run".format(name=test.__name__) - if six.PY3: + if not six.PY2: pytest.skip(msg) return test(*args, **kwargs) @@ -75,7 +75,7 @@ def onlyPy3(test): @functools.wraps(test) def wrapper(*args, **kwargs): msg = "{name} requires Python3.x to run".format(name=test.__name__) - if not six.PY3: + if six.PY2: pytest.skip(msg) return test(*args, **kwargs) diff --git a/test/appengine/conftest.py b/test/appengine/conftest.py index 9f17f42c..05bfefe7 100644 --- a/test/appengine/conftest.py +++ b/test/appengine/conftest.py @@ -72,7 +72,7 @@ def sandbox(testbed): def pytest_ignore_collect(path, config): """Skip App Engine tests in python 3 or if no SDK is available.""" if "appengine" in str(path): - if six.PY3: + if not six.PY2: return True if not os.environ.get("GAE_SDK_PATH"): return True diff --git a/test/test_collections.py b/test/test_collections.py index cb673ac2..e7be33fb 100644 --- a/test/test_collections.py +++ b/test/test_collections.py @@ -344,7 +344,7 @@ class TestHTTPHeaderDict(object): HTTPHeaderDict({3: 3}) @pytest.mark.skipif( - six.PY3, reason="python3 has a different internal header implementation" + not six.PY2, reason="python3 has a different internal header implementation" ) def test_from_httplib_py2(self): msg = """ |