Skip to content

Commit 47cb6fc

Browse files
authored
Merge branch 'master' into 5367
2 parents 50c985b + 1b41763 commit 47cb6fc

File tree

10 files changed

+57
-30
lines changed

10 files changed

+57
-30
lines changed

HISTORY.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,25 @@ Release History
44
dev
55
---
66

7-
**Bugfixes**
8-
97
- \[Short description of non-trivial change.\]
108

9+
2.24.0 (2020-06-17)
10+
-------------------
11+
12+
**Improvements**
13+
14+
- pyOpenSSL TLS implementation is now only used if Python
15+
either doesn't have an `ssl` module or doesn't support
16+
SNI. Previously pyOpenSSL was unconditionally used if available.
17+
This applies even if pyOpenSSL is installed via the
18+
`requests[security]` extra (#5443)
19+
20+
- Redirect resolution should now only occur when
21+
`allow_redirects` is True. (#5492)
22+
23+
- No longer perform unnecessary Content-Length calculation for
24+
requests that won't use it. (#5496)
25+
1126
2.23.0 (2020-02-19)
1227
-------------------
1328

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ by <a href="https://kennethreitz.org/">Kenneth Reitz</a> & is protected by The <
2828

2929
<p>&nbsp;</p>
3030

31-
```pycon
31+
```python
3232
>>> import requests
3333
>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
3434
>>> r.status_code
@@ -52,7 +52,7 @@ by <a href="https://kennethreitz.org/">Kenneth Reitz</a> & is protected by The <
5252
Requests allows you to send HTTP/1.1 requests extremely easily. There’s no need to manually add query strings to your URLs, or to form-encode your `PUT` & `POST` data — but nowadays, just use the `json` method!
5353

5454

55-
Requests is **the most downloaded Python package today**, pulling in around `14M downloads / week`— according to GitHub, Requests is currently [depended upon](https://github.com/psf/requests/network/dependents?package_id=UGFja2FnZS01NzA4OTExNg%3D%3D) by `367_296` repositories. You may certainly put your trust in this code.
55+
Requests is one of the most downloaded Python package today, pulling in around `14M downloads / week`— according to GitHub, Requests is currently [depended upon](https://github.com/psf/requests/network/dependents?package_id=UGFja2FnZS01NzA4OTExNg%3D%3D) by `500,000+` repositories. You may certainly put your trust in this code.
5656

5757

5858
<p>&nbsp;</p>
@@ -89,7 +89,7 @@ Requests is ready for the demands of building robust and reliable HTTP–speak a
8989
Requests Module Installation
9090
----------------------------
9191

92-
The recommended way to intall the `requests` module is to simply use [`pipenv`](https://pipenv.kennethreitz.org) (or `pip`, of
92+
The recommended way to install the `requests` module is to simply use [`pipenv`](https://pipenv.kennethreitz.org) (or `pip`, of
9393
course):
9494

9595
```console

docs/dev/todo.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Requests currently supports the following versions of Python:
5858
- Python 3.7
5959
- PyPy
6060

61-
Google AppEngine is not officially supported although support is available
61+
Google App Engine is not officially supported although support is available
6262
with the `Requests-Toolbelt`_.
6363

6464
.. _Requests-Toolbelt: https://toolbelt.readthedocs.io/

docs/user/advanced.rst

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
Advanced Usage
44
==============
55

6-
.. image:: https://farm5.staticflickr.com/4263/35163665790_d182d84f5e_k_d.jpg
7-
86
This document covers some of Requests more advanced features.
97

108
.. _session-objects:

requests/__init__.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,22 @@ def _check_cryptography(cryptography_version):
9090
"version!".format(urllib3.__version__, chardet.__version__),
9191
RequestsDependencyWarning)
9292

93-
# Attempt to enable urllib3's SNI support, if possible
93+
# Attempt to enable urllib3's fallback for SNI support
94+
# if the standard library doesn't support SNI or the
95+
# 'ssl' library isn't available.
9496
try:
95-
from urllib3.contrib import pyopenssl
96-
pyopenssl.inject_into_urllib3()
97+
try:
98+
import ssl
99+
except ImportError:
100+
ssl = None
101+
102+
if not getattr(ssl, "HAS_SNI", False):
103+
from urllib3.contrib import pyopenssl
104+
pyopenssl.inject_into_urllib3()
97105

98-
# Check cryptography version
99-
from cryptography import __version__ as cryptography_version
100-
_check_cryptography(cryptography_version)
106+
# Check cryptography version
107+
from cryptography import __version__ as cryptography_version
108+
_check_cryptography(cryptography_version)
101109
except ImportError:
102110
pass
103111

requests/__version__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
__title__ = 'requests'
66
__description__ = 'Python HTTP for Humans.'
77
__url__ = 'https://requests.readthedocs.io'
8-
__version__ = '2.23.0'
9-
__build__ = 0x022300
8+
__version__ = '2.24.0'
9+
__build__ = 0x022400
1010
__author__ = 'Kenneth Reitz'
1111
__author_email__ = '[email protected]'
1212
__license__ = 'Apache 2.0'

requests/models.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,9 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
273273
"""The fully mutable :class:`PreparedRequest <PreparedRequest>` object,
274274
containing the exact bytes that will be sent to the server.
275275
276-
Generated from either a :class:`Request <Request>` object or manually.
276+
Instances are generated from a :class:`Request <Request>` object, and
277+
should not be instantiated manually; doing so may produce undesirable
278+
effects.
277279
278280
Usage::
279281
@@ -473,12 +475,12 @@ def prepare_body(self, data, files, json=None):
473475
not isinstance(data, (basestring, list, tuple, Mapping))
474476
])
475477

476-
try:
477-
length = super_len(data)
478-
except (TypeError, AttributeError, UnsupportedOperation):
479-
length = None
480-
481478
if is_stream:
479+
try:
480+
length = super_len(data)
481+
except (TypeError, AttributeError, UnsupportedOperation):
482+
length = None
483+
482484
body = data
483485

484486
if getattr(body, 'tell', None) is not None:
@@ -916,7 +918,7 @@ def links(self):
916918
return l
917919

918920
def raise_for_status(self):
919-
"""Raises stored :class:`HTTPError`, if one occurred."""
921+
"""Raises :class:`HTTPError`, if one occurred."""
920922

921923
http_error_msg = ''
922924
if isinstance(self.reason, bytes):

requests/sessions.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -658,11 +658,13 @@ def send(self, request, **kwargs):
658658

659659
extract_cookies_to_jar(self.cookies, request, r.raw)
660660

661-
# Redirect resolving generator.
662-
gen = self.resolve_redirects(r, request, **kwargs)
663-
664661
# Resolve redirects if allowed.
665-
history = [resp for resp in gen] if allow_redirects else []
662+
if allow_redirects:
663+
# Redirect resolving generator.
664+
gen = self.resolve_redirects(r, request, **kwargs)
665+
history = [resp for resp in gen]
666+
else:
667+
history = []
666668

667669
# Shuffle things around if there's history.
668670
if history:

requests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def get_netrc_auth(url, raise_errors=False):
212212
if raise_errors:
213213
raise
214214

215-
# AppEngine hackiness.
215+
# App Engine hackiness.
216216
except (ImportError, AttributeError):
217217
pass
218218

tests/test_requests.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,10 @@ def __len__(self):
776776
def test_conflicting_post_params(self, httpbin):
777777
url = httpbin('post')
778778
with open('Pipfile') as f:
779-
pytest.raises(ValueError, "requests.post(url, data='[{\"some\": \"data\"}]', files={'some': f})")
780-
pytest.raises(ValueError, "requests.post(url, data=u('[{\"some\": \"data\"}]'), files={'some': f})")
779+
with pytest.raises(ValueError):
780+
requests.post(url, data='[{"some": "data"}]', files={'some': f})
781+
with pytest.raises(ValueError):
782+
requests.post(url, data=u('[{"some": "data"}]'), files={'some': f})
781783

782784
def test_request_ok_set(self, httpbin):
783785
r = requests.get(httpbin('status', '404'))

0 commit comments

Comments
 (0)