Account for missing argument in python2.6 HTTPConnection

This is getting a) complicated b) tiresome.
This commit is contained in:
Chris Dent
2013-11-05 20:46:25 +00:00
parent d70dfa9e20
commit e9c515602c
2 changed files with 14 additions and 6 deletions

View File

@@ -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()

View File

@@ -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)