Skip to content

Commit 16ce69e

Browse files
[3.13] gh-141938: document treatment of OSError raised by HTTPConnection.getresponse (GH-142339) (#142705)
gh-141938: document treatment of `OSError` raised by `HTTPConnection.getresponse` (GH-142339) (cherry picked from commit 11aef21) Co-authored-by: Bénédikt Tran <[email protected]>
1 parent d209fd9 commit 16ce69e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Doc/library/http.client.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@ HTTPConnection Objects
311311
:class:`str` or bytes-like object that is not also a file as the
312312
body representation.
313313

314+
.. note::
315+
316+
Note that you must have read the whole response or call :meth:`close`
317+
if :meth:`getresponse` raised an non-:exc:`ConnectionError` exception
318+
before you can send a new request to the server.
319+
314320
.. versionchanged:: 3.2
315321
*body* can now be an iterable.
316322

@@ -326,16 +332,15 @@ HTTPConnection Objects
326332
Should be called after a request is sent to get the response from the server.
327333
Returns an :class:`HTTPResponse` instance.
328334

329-
.. note::
330-
331-
Note that you must have read the whole response before you can send a new
332-
request to the server.
333-
334335
.. versionchanged:: 3.5
335336
If a :exc:`ConnectionError` or subclass is raised, the
336337
:class:`HTTPConnection` object will be ready to reconnect when
337338
a new request is sent.
338339

340+
Note that this does not apply to :exc:`OSError`\s raised by the underlying
341+
socket. Instead the caller is responsible to call :meth:`close` on the
342+
existing connection.
343+
339344

340345
.. method:: HTTPConnection.set_debuglevel(level)
341346

0 commit comments

Comments
 (0)