diff --git a/test/test_wsgi_compliance.py b/test/test_wsgi_compliance.py index 12a7c65..f52cfec 100644 --- a/test/test_wsgi_compliance.py +++ b/test/test_wsgi_compliance.py @@ -63,7 +63,7 @@ def test_script_name(): http_uninstall() -@py.test.mark.xfail(sys.version_info[0] == 2 and sys.version_info[1] <= 6, +py.test.mark.xfail(sys.version_info[0] == 2 and sys.version_info[1] <= 6, reason='works okay on 2.7 and beyond. why?') def test_encoding_errors(): http_install() diff --git a/wsgi_intercept/httplib2_intercept.py b/wsgi_intercept/httplib2_intercept.py index fd2a02a..0691b8f 100644 --- a/wsgi_intercept/httplib2_intercept.py +++ b/wsgi_intercept/httplib2_intercept.py @@ -20,8 +20,12 @@ class HTTP_WSGIInterceptorWithTimeout(InterceptorMixin, # In Python3 strict is deprecated if sys.version_info[0] < 3: - HTTPConnection.__init__(self, host, port=port, strict=strict, - timeout=timeout, source_address=source_address) + try: + HTTPConnection.__init__(self, host, port=port, strict=strict, + timeout=timeout, source_address=source_address) + except TypeError: # Python 2.6 doesn't have source_address + HTTPConnection.__init__(self, host, port=port, strict=strict, + timeout=timeout) else: HTTPConnection.__init__(self, host, port=port, timeout=timeout, source_address=source_address) @@ -36,10 +40,14 @@ class HTTPS_WSGIInterceptorWithTimeout(InterceptorMixin, # ignore proxy_info and ca_certs # In Python3 strict is deprecated if sys.version_info[0] < 3: - HTTPConnection.__init__(self, host, port=port, strict=strict, - timeout=timeout, source_address=source_address) + try: + HTTPSConnection.__init__(self, host, port=port, strict=strict, + timeout=timeout, source_address=source_address) + except TypeError: # Python 2.6 doesn't have source_address + HTTPSConnection.__init__(self, host, port=port, strict=strict, + timeout=timeout) else: - HTTPConnection.__init__(self, host, port=port, + HTTPSConnection.__init__(self, host, port=port, timeout=timeout, source_address=source_address)