Farewell, sweet Concorde!
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Formally removing any remaining vestiges of Python 2 from Requests. We'll also leave behind Python 3.6 while we're at it.
authored by Nate Prewitt · committed by GitHub · parent 79f6027 · Browse files · 19 files·+139 added−178 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
19 files+139 added−178 removed
- tests:+46 added−52 removed
- other:+93 added−126 removed
Provenance
- Commit
8bce583- Tree
05defac- Author
Nate Prewitt <nate.prewitt@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
79f6027
19 files changed+139 added−178 removed
modified:.github/workflows/run-tests.yml+2 added-5 removed
7 unmodified lines891011121213141515161718191718192015 unmodified lines7 unmodified lines timeout-minutes: 10 strategy: fail-fast: false matrix: python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"] python-version: ["3.7", "3.8", "3.9", "3.10"] os: [ubuntu-18.04, macOS-latest, windows-latest] include: # pypy3 on Mac OS currently fails trying to compile # pypy-3.7 on Mac OS currently fails trying to compile # brotlipy. Moving pypy3 to only test linux. - python-version: pypy3 os: ubuntu-latest experimental: false - python-version: pypy-3.7 os: ubuntu-latest experimental: false - python-version: 3.11-dev15 unmodified linesmodified:docs/community/faq.rst+6 added-9 removed
53 unmodified lines54 55 Python 3 Support?56 -----------------57 58-Yes! Requests officially supports Python 2.7 & 3.6+ and PyPy.58+Yes! Requests officially supports Python 3.7+ and PyPy.59 60 Python 2 Support?61 -----------------62 63-Yes! We understand that we have a large user base with varying needs. Through64-**at least** Requests 2.27.x, we will be providing continued support for Python65-2.7. However, this support is likely to end some time in 2022.63+No! As of Requests 2.28.0, Requests no longer supports Python 2.7. Users who64+have been unable to migrate should pin to `requests<2.28`. Full information65+can be found in `psf/requests#6023 <https://github.com/psf/requests/issues/6023>`_.66 67-It is *highly* recommended users migrate to Python 3.7+ now since Python67+It is *highly* recommended users migrate to Python 3.8+ now since Python68 2.7 is no longer receiving bug fixes or security updates as of January 1, 2020.69 70 What are "hostname doesn't match" errors?71 -----------------------------------------10 unmodified lines82 when servers are using `Virtual Hosting`_. When such servers are hosting83 more than one SSL site they need to be able to return the appropriate84 certificate based on the hostname the client is connecting to.85 86-Python3 and Python 2.7.9+ include native support for SNI in their SSL modules.87-For information on using SNI with Requests on Python < 2.7.9 refer to this88-`Stack Overflow answer`_.86+Python 3 already includes native support for SNI in their SSL modules.87 88 .. _`Server-Name-Indication`: https://en.wikipedia.org/wiki/Server_Name_Indication89 .. _`virtual hosting`: https://en.wikipedia.org/wiki/Virtual_hosting92-.. _`Stack Overflow answer`: https://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support/18579484#18579484modified:docs/index.rst+1 added-1 removed
70 unmodified lines71 - Connection Timeouts72 - Chunked Requests73 - ``.netrc`` Support74 75-Requests officially supports Python 2.7 & 3.6+, and runs great on PyPy.75+Requests officially supports Python 3.7+, and runs great on PyPy.76 77 78 The User Guide79 --------------61 unmodified linesmodified:requests/_internal_utils.py+2 added-5 removed
6 unmodified lines7 Provides utility functions that are consumed internally by Requests8 which depend on extremely few external helpers (such as compat)9 """10 11-from .compat import is_py2, builtin_str, str11+from .compat import builtin_str12 13 14 def to_native_string(string, encoding='ascii'):15 """Given a string object, regardless of type, returns a representation of2 unmodified lines18 """19 if isinstance(string, builtin_str):20 out = string21 else:22- if is_py2:23- out = string.encode(encoding)24- else:25- out = string.decode(encoding)22+ out = string.decode(encoding)23 24 return out25 26 13 unmodified linesmodified:requests/adapters.py+1 added-6 removed
475 unmodified lines476 low_conn.send(b'\r\n')477 low_conn.send(b'0\r\n\r\n')478 479 # Receive the response from the server480- try:481- # For Python 2.7, use buffering of HTTP responses482- r = low_conn.getresponse(buffering=True)483- except TypeError:484- # For compatibility with Python 3.3+485- r = low_conn.getresponse()480+ r = low_conn.getresponse()481 482 resp = HTTPResponse.from_httplib(483 r,484 pool=conn,49 unmodified linesmodified:requests/compat.py+24 added-42 removed
2 unmodified lines3 """4 requests.compat5 ~~~~~~~~~~~~~~~6 7-This module handles import compatibility issues between Python 2 and8-Python 3.7+This module previously handled import compatibility issues8+between Python 2 and Python 3. It remains for backwards9+compatibility until the next major version.10 """11 12 try:13 import chardet14 unmodified lines28 29 #: Python 3.x?30 is_py3 = (_ver[0] == 3)31 32+# json/simplejson module import resolution33 has_simplejson = False34 try:35 import simplejson as json36 has_simplejson = True37 except ImportError:38 import json39 40+if has_simplejson:41+ from simplejson import JSONDecodeError42+else:43+ from json import JSONDecodeError44+45 # ---------39-# Specifics46+# Legacy Imports47 # ---------48+from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag49+from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment50+from http import cookiejar as cookielib51+from http.cookies import Morsel52+from io import StringIO53 42-if is_py2:43- from urllib import (44- quote, unquote, quote_plus, unquote_plus, urlencode, getproxies,45- proxy_bypass, proxy_bypass_environment, getproxies_environment)46- from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag47- from urllib2 import parse_http_list48- import cookielib49- from Cookie import Morsel50- from StringIO import StringIO51- # Keep OrderedDict for backwards compatibility.52- from collections import Callable, Mapping, MutableMapping, OrderedDict54+# Keep OrderedDict for backwards compatibility.55+from collections import OrderedDict56+from collections.abc import Callable, Mapping, MutableMapping57 54- builtin_str = str55- bytes = str56- str = unicode57- basestring = basestring58- numeric_types = (int, long, float)59- integer_types = (int, long)60- JSONDecodeError = ValueError61-62-elif is_py3:63- from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag64- from urllib.request import parse_http_list, getproxies, proxy_bypass, proxy_bypass_environment, getproxies_environment65- from http import cookiejar as cookielib66- from http.cookies import Morsel67- from io import StringIO68- # Keep OrderedDict for backwards compatibility.69- from collections import OrderedDict70- from collections.abc import Callable, Mapping, MutableMapping71- if has_simplejson:72- from simplejson import JSONDecodeError73- else:74- from json import JSONDecodeError75-76- builtin_str = str77- str = str78- bytes = bytes79- basestring = (str, bytes)80- numeric_types = (int, float)81- integer_types = (int,)58+builtin_str = str59+str = str60+bytes = bytes61+basestring = (str, bytes)62+numeric_types = (int, float)63+integer_types = (int,)modified:requests/help.py+2 added-2 removed
34 unmodified lines35 def _implementation():36 """Return a dict with the Python implementation and version.37 38 Provide both the name and the version of the Python implementation39- currently running. For example, on CPython 2.7.5 it will return40- {'name': 'CPython', 'version': '2.7.5'}.39+ currently running. For example, on CPython 3.10.3 it will return40+ {'name': 'CPython', 'version': '3.10.3'}.41 42 This function works best on CPython and PyPy: in particular, it probably43 doesn't work for Jython or IronPython. Future investigation should be done44 to work out the correct shape of the code for those platforms.91 unmodified linesmodified:requests/models.py+4 added-20 removed
6 unmodified lines7 This module contains the primary objects that power Requests.8 """9 10 import datetime11-import sys11 12 # Import encoding now, to avoid implicit import later.13 # Implicit import within threads may cause LookupError when standard library is in a ZIP,14 # such as in Embedded Python. See https://github.com/psf/requests/issues/3578.28 unmodified lines43 stream_decode_response_unicode, to_key_val_list, parse_header_links,44 iter_slices, guess_json_utf, super_len, check_header_validity)45 from .compat import (46 Callable, Mapping,48- cookielib, urlunparse, urlsplit, urlencode, str, bytes,49- is_py2, chardet, builtin_str, basestring, JSONDecodeError)47+ cookielib, urlunparse, urlsplit, urlencode,48+ chardet, builtin_str, basestring, JSONDecodeError)49 from .compat import json as complexjson50 from .status_codes import codes51 52 #: The set of HTTP status codes that indicate an automatically318 unmodified lines371 #: https://github.com/psf/requests/pull/2238372 if isinstance(url, bytes):373 url = url.decode('utf8')374 else:376- url = unicode(url) if is_py2 else str(url)375+ url = str(url)376 377 # Remove leading whitespaces from url378 url = url.lstrip()379 42 unmodified lines422 # Bare domains aren't valid URLs.423 if not path:424 path = '/'425 427- if is_py2:428- if isinstance(scheme, str):429- scheme = scheme.encode('utf-8')430- if isinstance(netloc, str):431- netloc = netloc.encode('utf-8')432- if isinstance(path, str):433- path = path.encode('utf-8')434- if isinstance(query, str):435- query = query.encode('utf-8')436- if isinstance(fragment, str):437- fragment = fragment.encode('utf-8')438-426 if isinstance(params, (str, bytes)):427 params = to_native_string(params)428 429 enc_params = self._encode_params(params)475 unmodified lines905 return complexjson.loads(self.text, **kwargs)906 except JSONDecodeError as e:907 # Catch JSON-related errors and raise as requests.JSONDecodeError908 # This aliases json.JSONDecodeError and simplejson.JSONDecodeError922- if is_py2: # e is a ValueError923- raise RequestsJSONDecodeError(e.message)924- else:925- raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)909+ raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)910 911 @property912 def links(self):913 """Returns the parsed header links of the response, if any."""52 unmodified linesmodified:requests/sessions.py+3 added-7 removed
12 unmodified lines13 from datetime import timedelta14 from collections import OrderedDict15 16 from .auth import _basic_auth_str17-from .compat import cookielib, is_py3, urljoin, urlparse, Mapping17+from .compat import cookielib, urljoin, urlparse, Mapping18 from .cookies import (19 cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies)20 from .models import Request, PreparedRequest, DEFAULT_REDIRECT_LIMIT21 from .hooks import default_hooks, dispatch_hook16 unmodified lines38 from .models import REDIRECT_STATI39 40 # Preferred clock, based on which one is more accurate on a given system.41 if sys.platform == 'win32':42- try: # Python 3.4+43- preferred_clock = time.perf_counter42+ preferred_clock = time.perf_counter44- except AttributeError: # Earlier than Python 3.45- preferred_clock = time.clock43 else:44 preferred_clock = time.time45 46 60 unmodified lines107 # rarely used with non-ASCII characters in HTTP headers.108 # It is more likely to get UTF8 header rather than latin1.109 # This causes incorrect handling of UTF8 encoded location headers.110 # To solve this, we re-encode the location in latin1.114- if is_py3:115- location = location.encode('latin1')111+ location = location.encode('latin1')112 return to_native_string(location, 'utf8')113 return None114 115 def should_strip_auth(self, old_url, new_url):659 unmodified linesmodified:requests/utils.py+3 added-7 removed
28 unmodified lines29 from ._internal_utils import to_native_string30 from .compat import parse_http_list as _parse_list_header31 from .compat import (32 quote, urlparse, bytes, str, unquote, getproxies,33- proxy_bypass, urlunparse, basestring, integer_types, is_py3,33+ proxy_bypass, urlunparse, basestring, integer_types,34 proxy_bypass_environment, getproxies_environment, Mapping)35 from .cookies import cookiejar_from_dict36 from .structures import CaseInsensitiveDict37 from .exceptions import (15 unmodified lines53 # provide a proxy_bypass version on Windows without DNS lookups54 55 def proxy_bypass_registry(host):56 try:57- if is_py3:58- import winreg57+ import winreg59- else:60- import _winreg as winreg58 except ImportError:59 return False60 61 try:215 unmodified lines277 278 @contextlib.contextmanager279 def atomic_open(filename):280 """Write a file to the disk in an atomic fashion"""284- replacer = os.rename if sys.version_info[0] == 2 else os.replace281 tmp_descriptor, tmp_name = tempfile.mkstemp(dir=os.path.dirname(filename))282 try:283 with os.fdopen(tmp_descriptor, 'wb') as tmp_handler:284 yield tmp_handler289- replacer(tmp_name, filename)285+ os.replace(tmp_name, filename)286 except BaseException:287 os.remove(tmp_name)288 raise289 767 unmodified linesmodified:tests/testserver/server.py+1 added-3 removed
76 unmodified lines77 78 def _create_socket_and_bind(self):79 sock = socket.socket()80 sock.bind((self.host, self.port))81- # NB: when Python 2.7 is no longer supported, the argument82- # can be removed to use a default backlog size83- sock.listen(5)81+ sock.listen()82 return sock83 84 def _close_server_sock_ignore_errors(self):85 try:43 unmodified linesmodified:tests/compat.py+12 added-9 removed
1 # -*- coding: utf-8 -*-2+import warnings3 3-from requests.compat import is_py34-5-4 try:5 import StringIO6 except ImportError:7 import io as StringIO2 unmodified lines10 from cStringIO import StringIO as cStringIO11 except ImportError:12 cStringIO = None13 16-if is_py3:17- def u(s):18- return s19-else:20- def u(s):21- return s.decode('unicode-escape')14+15+def u(s):16+ warnings.warn(17+ (18+ "This helper function is no longer relevant in Python 3. "19+ "Usage of this alias should be discontinued as it will be "20+ "removed in a future release of Requests."21+ ),22+ DeprecationWarning,23+ )24+ return smodified:tests/test_requests.py+32 added-36 removed
1 # -*- coding: utf-8 -*-2 3 """Tests for Requests."""4 5-from __future__ import division5 import json6 import os7 import pickle8 import collections7 unmodified lines16 import urllib317 from requests.adapters import HTTPAdapter18 from requests.auth import HTTPDigestAuth, _basic_auth_str19 from requests.compat import (21- Morsel, cookielib, getproxies, str, urlparse,20+ Morsel, cookielib, getproxies, urlparse,21 builtin_str)22 from requests.cookies import (23 cookiejar_from_dict, morsel_to_cookie)24 from requests.exceptions import (20 unmodified lines45 from requests.structures import CaseInsensitiveDict46 from requests.sessions import SessionRedirectMixin47 from requests.models import urlencode48 from requests.hooks import default_hooks50-from requests.compat import JSONDecodeError, is_py3, MutableMapping49+from requests.compat import JSONDecodeError, MutableMapping50 52-from .compat import StringIO, u51+from .compat import StringIO52 from .utils import override_environ53 from urllib3.util import Timeout as Urllib3Timeout54 55 # Requests to this URL should always fail with a connection timeout (nothing461 unmodified lines517 518 @pytest.mark.parametrize(519 'username, password', (520 ('user', 'pass'),522- (u'имя'.encode('utf-8'), u'пароль'.encode('utf-8')),521+ ('имя'.encode('utf-8'), 'пароль'.encode('utf-8')),522 (42, 42),523 (None, None),524 ))525 def test_set_basicauth(self, httpbin, username, password):315 unmodified lines841 url = httpbin('post')842 with open('requirements-dev.txt') as f:843 with pytest.raises(ValueError):844 requests.post(url, data='[{"some": "data"}]', files={'some': f})846- with pytest.raises(ValueError):847- requests.post(url, data=u('[{"some": "data"}]'), files={'some': f})845 846 def test_request_ok_set(self, httpbin):847 r = requests.get(httpbin('status', '404'))848 assert not r.ok136 unmodified lines985 assert r.status_code == 200986 987 @pytest.mark.parametrize(988 'data', (992- {'stuff': u('ëlïxr')},993- {'stuff': u('ëlïxr').encode('utf-8')},989+ {'stuff': 'ëlïxr'},990+ {'stuff': 'ëlïxr'.encode('utf-8')},991 {'stuff': 'elixr'},992 {'stuff': 'elixr'.encode('utf-8')},993 ))994 def test_unicode_multipart_post(self, httpbin, data):14 unmodified lines1009 1010 def test_unicode_method_name(self, httpbin):1011 files = {'file': open(__file__, 'rb')}1012 r = requests.request(1016- method=u('POST'), url=httpbin('post'), files=files)1013+ method='POST', url=httpbin('post'), files=files)1014 assert r.status_code == 2001015 1016 def test_unicode_method_name_with_request_object(self, httpbin):1017 files = {'file': open(__file__, 'rb')}1018 s = requests.Session()1022- req = requests.Request(u('POST'), httpbin('post'), files=files)1019+ req = requests.Request('POST', httpbin('post'), files=files)1020 prep = s.prepare_request(req)1021 assert isinstance(prep.method, builtin_str)1022 assert prep.method == 'POST'1023 1 unmodified line1025 assert resp.status_code == 2001026 1027 def test_non_prepared_request_error(self):1028 s = requests.Session()1032- req = requests.Request(u('POST'), '/')1029+ req = requests.Request('POST', '/')1030 1031 with pytest.raises(ValueError) as e:1032 s.send(req)1033 assert str(e.value) == 'You can only send PreparedRequests.'298 unmodified lines1332 1333 def test_response_reason_unicode(self):1334 # check for unicode HTTP status1335 r = requests.Response()1339- r.url = u'unicode URL'1340- r.reason = u'Komponenttia ei löydy'.encode('utf-8')1336+ r.url = 'unicode URL'1337+ r.reason = 'Komponenttia ei löydy'.encode('utf-8')1338 r.status_code = 4041339 r.encoding = None1340 assert not r.ok # old behaviour - crashes here1341 1342 def test_response_reason_unicode_fallback(self):1343 # check raise_status falls back to ISO-8859-11344 r = requests.Response()1345 r.url = 'some url'1349- reason = u'Komponenttia ei löydy'1346+ reason = 'Komponenttia ei löydy'1347 r.reason = reason.encode('latin-1')1348 r.status_code = 5001349 r.encoding = None1350 with pytest.raises(requests.exceptions.HTTPError) as e:238 unmodified lines1589 r = requests.Request('GET', url).prepare()1590 assert r.url == url1591 1592 def test_header_keys_are_native(self, httpbin):1596- headers = {u('unicode'): 'blah', 'byte'.encode('ascii'): 'blah'}1593+ headers = {'unicode': 'blah', 'byte'.encode('ascii'): 'blah'}1594 r = requests.Request('GET', httpbin('get'), headers=headers)1595 p = r.prepare()1596 1597 # This is testing that they are builtin strings. A bit weird, but there3 unmodified lines1601 1602 def test_header_validation(self, httpbin):1603 """Ensure prepare_headers regex isn't flagging valid header contents."""1604 headers_ok = {'foo': 'bar baz qux',1608- 'bar': u'fbbq'.encode('utf8'),1605+ 'bar': 'fbbq'.encode('utf8'),1606 'baz': '',1607 'qux': '1'}1608 r = requests.get(httpbin('get'), headers=headers_ok)1609 assert r.request.headers['foo'] == headers_ok['foo']271 unmodified lines1881 1882 @pytest.mark.parametrize(1883 'username, password, auth_str', (1884 ('test', 'test', 'Basic dGVzdDp0ZXN0'),1888- (u'имя'.encode('utf-8'), u'пароль'.encode('utf-8'), 'Basic 0LjQvNGPOtC/0LDRgNC+0LvRjA=='),1885+ ('имя'.encode('utf-8'), 'пароль'.encode('utf-8'), 'Basic 0LjQvNGPOtC/0LDRgNC+0LvRjA=='),1886 ))1887 def test_basic_auth_str_is_always_native(self, username, password, auth_str):1888 s = _basic_auth_str(username, password)1889 assert isinstance(s, builtin_str)575 unmodified lines2465 'cookies': {'foo': 'bar'}2466 },2467 {2468 'method': 'GET',2472- 'url': u('http://www.example.com/üniçø∂é')2469+ 'url': 'http://www.example.com/üniçø∂é'2470 },2471 ))2472 def test_prepared_copy(kwargs):2473 p = PreparedRequest()29 unmodified lines2503 @pytest.mark.parametrize(2504 'url,expected',2505 (2506 ('http://google.com', 'http://google.com/'),2510- (u'http://ジェーピーニック.jp', u'http://xn--hckqz9bzb1cyrb.jp/'),2511- (u'http://xn--n3h.net/', u'http://xn--n3h.net/'),2507+ ('http://ジェーピーニック.jp', 'http://xn--hckqz9bzb1cyrb.jp/'),2508+ ('http://xn--n3h.net/', 'http://xn--n3h.net/'),2509 (2513- u'http://ジェーピーニック.jp'.encode('utf-8'),2514- u'http://xn--hckqz9bzb1cyrb.jp/'2510+ 'http://ジェーピーニック.jp'.encode('utf-8'),2511+ 'http://xn--hckqz9bzb1cyrb.jp/'2512 ),2513 (2517- u'http://straße.de/straße',2518- u'http://xn--strae-oqa.de/stra%C3%9Fe'2514+ 'http://straße.de/straße',2515+ 'http://xn--strae-oqa.de/stra%C3%9Fe'2516 ),2517 (2521- u'http://straße.de/straße'.encode('utf-8'),2522- u'http://xn--strae-oqa.de/stra%C3%9Fe'2518+ 'http://straße.de/straße'.encode('utf-8'),2519+ 'http://xn--strae-oqa.de/stra%C3%9Fe'2520 ),2521 (2525- u'http://Königsgäßchen.de/straße',2526- u'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2522+ 'http://Königsgäßchen.de/straße',2523+ 'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2524 ),2525 (2529- u'http://Königsgäßchen.de/straße'.encode('utf-8'),2530- u'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2526+ 'http://Königsgäßchen.de/straße'.encode('utf-8'),2527+ 'http://xn--knigsgchen-b4a3dun.de/stra%C3%9Fe'2528 ),2529 (2530 b'http://xn--n3h.net/',2534- u'http://xn--n3h.net/'2531+ 'http://xn--n3h.net/'2532 ),2533 (2534 b'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',2538- u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2535+ 'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2536 ),2537 (2541- u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',2542- u'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2538+ 'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/',2539+ 'http://[1200:0000:ab00:1234:0000:2552:7777:1313]:12345/'2540 )2541 )2542 )2543 def test_preparing_url(self, url, expected):116 unmodified lines2660 assert isinstance(excinfo.value, RequestException)2661 assert isinstance(excinfo.value, JSONDecodeError)2662 assert r.text not in str(excinfo.value)2663 2667- @pytest.mark.skipif(not is_py3, reason="doc attribute is only present on py3")2664 def test_json_decode_persists_doc_attr(self, httpbin):2665 r = requests.get(httpbin('bytes/20'))2666 with pytest.raises(requests.exceptions.JSONDecodeError) as excinfo:2667 r.json()1 unmodified linemodified:tests/test_utils.py+1 added-4 removed
747 unmodified lines748 can be bypassed or not with Windows registry settings749 """750 if override is None:751 override = '192.168.*;127.0.0.1;localhost.localdomain;172.16.1.1'752- if compat.is_py3:753- import winreg752+ import winreg754- else:755- import _winreg as winreg753 754 class RegHandle:755 def Close(self):756 pass50 unmodified linesmodified:HISTORY.md+5 added
9 unmodified lines10 11 - Fixed urllib3 exception leak, wrapping `urllib3.exceptions.SSLError` with12 `requests.exceptions.SSLError` for `content` and `iter_content`.13 14+**Deprecations**15+16+- ⚠️ Requests has officially dropped support for Python 2.7. ⚠️17+- Requests has officially dropped support for Python 3.6 (including pypy3).18+19 2.27.1 (2022-01-05)20 -------------------21 22 **Bugfixes**1795 unmodified linesmodified:README.md+1 added-1 removed
31 unmodified lines32 ```console33 $ python -m pip install requests34 ```35 36-Requests officially supports Python 2.7 & 3.6+.36+Requests officially supports Python 3.7+.37 38 ## Supported Features & Best–Practices39 40 Requests is ready for the demands of building robust and reliable HTTP–speaking applications, for the needs of today.38 unmodified linesmodified:setup.cfg+8 added-3 removed
1-[bdist_wheel]2-universal = 13-1 [metadata]2 license_file = LICENSE3+provides-extra =4+ socks5+ use_chardet_on_py36+requires-dist =7+ certifi>=2017.4.178+ charset_normalizer~=2.0.09+ idna>=2.5,<410+ urllib3>=1.21.1,<1.27modified:setup.py+30 added-17 removed
1 #!/usr/bin/env python2-# Learn more: https://github.com/kennethreitz/setup.py2 import os3 import sys4 5 from codecs import open6 7 from setuptools import setup8 from setuptools.command.test import test as TestCommand9 11-here = os.path.abspath(os.path.dirname(__file__))10 11+CURRENT_PYTHON = sys.version_info[:2]12+REQUIRED_PYTHON = (3, 7)13+14+if CURRENT_PYTHON < REQUIRED_PYTHON:15+ sys.stderr.write(16+ """17+==========================18+Unsupported Python version19+==========================20+This version of Requests requires at least Python {}.{}, but21+you're trying to install it on Python {}.{}. To resolve this,22+consider upgrading to a supported Python version.23+24+If you can't upgrade your Python version, you'll need to25+pin to an older version of Requests (<2.28).26+""".format(27+ *(REQUIRED_PYTHON + CURRENT_PYTHON)28+ )29+ )30+ sys.exit(1)31+32 class PyTest(TestCommand):33 user_options = [('pytest-args=', 'a', "Arguments to pass into py.test")]34 35 def initialize_options(self):20 unmodified lines56 os.system('python setup.py sdist bdist_wheel')57 os.system('twine upload dist/*')58 sys.exit()59 41-packages = ['requests']42-60 requires = [44- 'charset_normalizer~=2.0.0; python_version >= "3"',45- 'chardet>=3.0.2,<5; python_version < "3"',46- 'idna>=2.5,<3; python_version < "3"',47- 'idna>=2.5,<4; python_version >= "3"',61+ 'charset_normalizer~=2.0.0',62+ 'idna>=2.5,<4',63 'urllib3>=1.21.1,<1.27',49- 'certifi>=2017.4.17'50-64+ 'certifi>=2017.4.17',65 ]66 test_requirements = [67 'pytest-httpbin==0.0.7',68 'pytest-cov',69 'pytest-mock',70 'pytest-xdist',71 'PySocks>=1.5.6, !=1.5.7',58- 'pytest>=3'72+ 'pytest>=3',73 ]74 75 about = {}76+here = os.path.abspath(os.path.dirname(__file__))77 with open(os.path.join(here, 'requests', '__version__.py'), 'r', 'utf-8') as f:78 exec(f.read(), about)79 80 with open('README.md', 'r', 'utf-8') as f:7 unmodified lines88 long_description_content_type='text/markdown',89 author=about['__author__'],90 author_email=about['__author_email__'],91 url=about['__url__'],77- packages=packages,92+ packages=['requests'],93 package_data={'': ['LICENSE', 'NOTICE']},94 package_dir={'requests': 'requests'},95 include_package_data=True,81- python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*",96+ python_requires=">=3.7, <4",97 install_requires=requires,98 license=about['__license__'],99 zip_safe=False,100 classifiers=[3 unmodified lines104 'License :: OSI Approved :: Apache Software License',105 'Natural Language :: English',106 'Operating System :: OS Independent',107 'Programming Language :: Python',93- 'Programming Language :: Python :: 2',94- 'Programming Language :: Python :: 2.7',108 'Programming Language :: Python :: 3',96- 'Programming Language :: Python :: 3.6',109 'Programming Language :: Python :: 3.7',110 'Programming Language :: Python :: 3.8',111 'Programming Language :: Python :: 3.9',112 'Programming Language :: Python :: 3.10',113+ 'Programming Language :: Python :: 3.11',114+ 'Programming Language :: Python :: 3 :: Only',115 'Programming Language :: Python :: Implementation :: CPython',116 'Programming Language :: Python :: Implementation :: PyPy',117 'Topic :: Internet :: WWW/HTTP',118 'Topic :: Software Development :: Libraries',2 unmodified lines121 tests_require=test_requirements,122 extras_require={123 'security': [],124 'socks': ['PySocks>=1.5.6, !=1.5.7'],111- 'socks:sys_platform == "win32" and python_version == "2.7"': ['win_inet_pton'],125 'use_chardet_on_py3': ['chardet>=3.0.2,<5']126 },127 project_urls={128 'Documentation': 'https://requests.readthedocs.io',3 unmodified linesmodified:tox.ini+1 added-1 removed
1 [tox]2-envlist = py{27,36,37,38,39}-{default,use_chardet_on_py3}2+envlist = py{37,38,39,310}-{default, use_chardet_on_py3}3 4 [testenv]5 deps = -rrequirements-dev.txt6 extras =12 unmodified lines