Use six to patch HTTPMessage so that it works on Python 2 and Python 3
This commit is contained in:
parent
ffffe5411e
commit
b57a27da28
3
setup.py
3
setup.py
|
@ -15,6 +15,9 @@ setup_params = dict(
|
|||
url="https://bitbucket.org/jaraco/wolframalpha",
|
||||
packages=setuptools.find_packages(),
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
'six',
|
||||
],
|
||||
setup_requires=[
|
||||
'hgtools',
|
||||
'pytest-runner',
|
||||
|
|
|
@ -7,6 +7,10 @@ except ImportError:
|
|||
|
||||
from xml.etree import ElementTree as etree
|
||||
|
||||
from . import compat
|
||||
|
||||
compat.fix_HTTPMessage()
|
||||
|
||||
class Result(object):
|
||||
def __init__(self, stream):
|
||||
self.tree = etree.parse(stream)
|
||||
|
|
14
wolframalpha/compat.py
Normal file
14
wolframalpha/compat.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import six
|
||||
from six.moves import http_client
|
||||
|
||||
def fix_HTTPMessage():
|
||||
"""
|
||||
Python 2 uses a deprecated method signature and doesn't provide the
|
||||
forward compatibility.
|
||||
Add it.
|
||||
"""
|
||||
if six.PY3:
|
||||
return
|
||||
|
||||
http_client.HTTPMessage.get_content_type = http_client.HTTPMessage.gettype
|
||||
http_client.HTTPMessage.get_param = http_client.HTTPMessage.getparam
|
Loading…
Reference in New Issue
Block a user