Mercurial > repos > guerler > hhblits
comparison lib/python3.8/site-packages/pip/_vendor/requests/compat.py @ 0:9e54283cc701 draft
"planemo upload commit d12c32a45bcd441307e632fca6d9af7d60289d44"
author | guerler |
---|---|
date | Mon, 27 Jul 2020 03:47:31 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:9e54283cc701 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 """ | |
4 requests.compat | |
5 ~~~~~~~~~~~~~~~ | |
6 | |
7 This module handles import compatibility issues between Python 2 and | |
8 Python 3. | |
9 """ | |
10 | |
11 from pip._vendor import chardet | |
12 | |
13 import sys | |
14 | |
15 # ------- | |
16 # Pythons | |
17 # ------- | |
18 | |
19 # Syntax sugar. | |
20 _ver = sys.version_info | |
21 | |
22 #: Python 2.x? | |
23 is_py2 = (_ver[0] == 2) | |
24 | |
25 #: Python 3.x? | |
26 is_py3 = (_ver[0] == 3) | |
27 | |
28 # Note: We've patched out simplejson support in pip because it prevents | |
29 # upgrading simplejson on Windows. | |
30 # try: | |
31 # import simplejson as json | |
32 # except (ImportError, SyntaxError): | |
33 # # simplejson does not support Python 3.2, it throws a SyntaxError | |
34 # # because of u'...' Unicode literals. | |
35 import json | |
36 | |
37 # --------- | |
38 # Specifics | |
39 # --------- | |
40 | |
41 if is_py2: | |
42 from urllib import ( | |
43 quote, unquote, quote_plus, unquote_plus, urlencode, getproxies, | |
44 proxy_bypass, proxy_bypass_environment, getproxies_environment) | |
45 from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag | |
46 from urllib2 import parse_http_list | |
47 import cookielib | |
48 from Cookie import Morsel | |
49 from StringIO import StringIO | |
50 from collections import Callable, Mapping, MutableMapping, OrderedDict | |
51 | |
52 | |
53 builtin_str = str | |
54 bytes = str | |
55 str = unicode | |
56 basestring = basestring | |
57 numeric_types = (int, long, float) | |
58 integer_types = (int, long) | |
59 | |
60 elif is_py3: | |
61 from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag | |
62 from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment | |
63 from http import cookiejar as cookielib | |
64 from http.cookies import Morsel | |
65 from io import StringIO | |
66 from collections import OrderedDict | |
67 from collections.abc import Callable, Mapping, MutableMapping | |
68 | |
69 builtin_str = str | |
70 str = str | |
71 bytes = bytes | |
72 basestring = (str, bytes) | |
73 numeric_types = (int, float) | |
74 integer_types = (int,) |