Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/requests/compat.py : 66%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
3"""
4requests.compat
5~~~~~~~~~~~~~~~
7This module handles import compatibility issues between Python 2 and
8Python 3.
9"""
11import chardet
13import sys
15# -------
16# Pythons
17# -------
19# Syntax sugar.
20_ver = sys.version_info
22#: Python 2.x?
23is_py2 = (_ver[0] == 2)
25#: Python 3.x?
26is_py3 = (_ver[0] == 3)
28try:
29 import simplejson as json
30except ImportError:
31 import json
33# ---------
34# Specifics
35# ---------
37if is_py2:
38 from urllib import (
39 quote, unquote, quote_plus, unquote_plus, urlencode, getproxies,
40 proxy_bypass, proxy_bypass_environment, getproxies_environment)
41 from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag
42 from urllib2 import parse_http_list
43 import cookielib
44 from Cookie import Morsel
45 from StringIO import StringIO
46 # Keep OrderedDict for backwards compatibility.
47 from collections import Callable, Mapping, MutableMapping, OrderedDict
50 builtin_str = str
51 bytes = str
52 str = unicode
53 basestring = basestring
54 numeric_types = (int, long, float)
55 integer_types = (int, long)
57elif is_py3:
58 from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag
59 from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment
60 from http import cookiejar as cookielib
61 from http.cookies import Morsel
62 from io import StringIO
63 # Keep OrderedDict for backwards compatibility.
64 from collections import OrderedDict
65 from collections.abc import Callable, Mapping, MutableMapping
67 builtin_str = str
68 str = str
69 bytes = bytes
70 basestring = (str, bytes)
71 numeric_types = (int, float)
72 integer_types = (int,)