From e4bc363f9ec0440eca26c1d3f865e3036f6ceea4 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Tue, 24 Feb 2015 07:39:26 +0100 Subject: [PATCH] Don't depend on `requests.compat` #314 --- httpie/compat.py | 26 ++++++++++++++++++++------ httpie/context.py | 3 +-- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/httpie/compat.py b/httpie/compat.py index 6de02616..d78d94f3 100644 --- a/httpie/compat.py +++ b/httpie/compat.py @@ -2,12 +2,26 @@ 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, is_py27 -) +import sys + + +# Taken from `requests.compat` +_ver = sys.version_info +is_py2 = (_ver[0] == 2) +is_py26 = (is_py2 and _ver[1] == 6) +is_py27 = (is_py2 and _ver[1] == 7) +is_py3 = (_ver[0] == 3) +is_pypy = ('pypy' in _ver) +is_windows = 'win32' in str(sys.platform).lower() + + +if is_py2: + bytes = str + str = unicode +elif is_py3: + str = str + bytes = bytes + try: # pragma: no cover # noinspection PyUnresolvedReferences,PyCompatibility diff --git a/httpie/context.py b/httpie/context.py index 6be232c4..cd97831d 100644 --- a/httpie/context.py +++ b/httpie/context.py @@ -1,7 +1,6 @@ import sys -from requests.compat import is_windows - +from httpie.compat import is_windows from httpie.config import DEFAULT_CONFIG_DIR, Config