Path: blob/master/venv/Lib/site-packages/requests/compat.py
811 views
# -*- coding: utf-8 -*-12"""3requests.compat4~~~~~~~~~~~~~~~56This module handles import compatibility issues between Python 2 and7Python 3.8"""910import chardet1112import sys1314# -------15# Pythons16# -------1718# Syntax sugar.19_ver = sys.version_info2021#: Python 2.x?22is_py2 = (_ver[0] == 2)2324#: Python 3.x?25is_py3 = (_ver[0] == 3)2627try:28import simplejson as json29except ImportError:30import json3132# ---------33# Specifics34# ---------3536if is_py2:37from urllib import (38quote, unquote, quote_plus, unquote_plus, urlencode, getproxies,39proxy_bypass, proxy_bypass_environment, getproxies_environment)40from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag41from urllib2 import parse_http_list42import cookielib43from Cookie import Morsel44from StringIO import StringIO45# Keep OrderedDict for backwards compatibility.46from collections import Callable, Mapping, MutableMapping, OrderedDict474849builtin_str = str50bytes = str51str = unicode52basestring = basestring53numeric_types = (int, long, float)54integer_types = (int, long)5556elif is_py3:57from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag58from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment59from http import cookiejar as cookielib60from http.cookies import Morsel61from io import StringIO62# Keep OrderedDict for backwards compatibility.63from collections import OrderedDict64from collections.abc import Callable, Mapping, MutableMapping6566builtin_str = str67str = str68bytes = bytes69basestring = (str, bytes)70numeric_types = (int, float)71integer_types = (int,)727374