mirror of
https://github.com/httpie/cli.git
synced 2024-11-08 08:55:05 +01:00
Added a PyPy incompatibility workaround.
This commit is contained in:
parent
985f65ef52
commit
bc0d17c04c
@ -4,7 +4,10 @@ Python 2.6, 2.7, and 3.x compatibility.
|
||||
"""
|
||||
# Borrow these from requests:
|
||||
# noinspection PyUnresolvedReferences
|
||||
from requests.compat import is_windows, bytes, str, is_py3, is_py26, is_pypy
|
||||
from requests.compat import (
|
||||
is_windows, bytes, str,
|
||||
is_py3, is_py26, is_pypy, is_py27
|
||||
)
|
||||
|
||||
try: # pragma: no cover
|
||||
# noinspection PyUnresolvedReferences,PyCompatibility
|
||||
|
@ -8,7 +8,7 @@ import errno
|
||||
import mimetypes
|
||||
import getpass
|
||||
from io import BytesIO
|
||||
from collections import namedtuple
|
||||
from collections import namedtuple, Iterable
|
||||
# noinspection PyCompatibility
|
||||
from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
||||
|
||||
@ -16,7 +16,7 @@ from argparse import ArgumentParser, ArgumentTypeError, ArgumentError
|
||||
# https://github.com/jakubroztocil/httpie/issues/130
|
||||
from requests.structures import CaseInsensitiveDict
|
||||
|
||||
from httpie.compat import OrderedDict, urlsplit, str
|
||||
from httpie.compat import OrderedDict, urlsplit, str, is_pypy, is_py27
|
||||
from httpie.sessions import VALID_SESSION_NAME_PATTERN
|
||||
from httpie.utils import load_json_preserve_order
|
||||
|
||||
@ -561,6 +561,17 @@ class AuthCredentialsArgType(KeyValueArgType):
|
||||
class RequestItemsDict(OrderedDict):
|
||||
"""Multi-value dict for URL parameters and form data."""
|
||||
|
||||
if is_pypy and is_py27:
|
||||
# Manually set keys when initialized with an iterable as PyPy
|
||||
# doesn't call __setitem__ in such case (pypy3 does).
|
||||
def __init__(self, *args, **kwargs):
|
||||
if len(args) == 1 and isinstance(args[0], Iterable):
|
||||
super(RequestItemsDict, self).__init__(**kwargs)
|
||||
for k, v in args[0]:
|
||||
self[k] = v
|
||||
else:
|
||||
super(RequestItemsDict, self).__init__(*args, **kwargs)
|
||||
|
||||
#noinspection PyMethodOverriding
|
||||
def __setitem__(self, key, value):
|
||||
""" If `key` is assigned more than once, `self[key]` holds a
|
||||
|
Loading…
Reference in New Issue
Block a user