https://github.com/python/cpython/commit/dcda3aaa6a6c279579da4b96747dc7c3c8216715
commit: dcda3aaa6a6c279579da4b96747dc7c3c8216715
branch: 3.11
author: Miss Islington (bot) <[email protected]>
committer: AA-Turner <[email protected]>
date: 2024-01-23T01:07:14Z
summary:

[3.11] gh-66944: Note that the `contextlib.closing` example is for illustrative 
purposes (GH-112198) (#114459)

files:
M Doc/library/contextlib.rst

diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index c01112a0a85895..fd264883c6823c 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -182,6 +182,14 @@ Functions and classes provided:
    without needing to explicitly close ``page``.  Even if an error occurs,
    ``page.close()`` will be called when the :keyword:`with` block is exited.
 
+   .. note::
+
+      Most types managing resources support the :term:`context manager` 
protocol,
+      which closes *thing* on leaving the :keyword:`with` statment.
+      As such, :func:`!closing` is most useful for third party types that don't
+      support context managers.
+      This example is purely for illustration purposes,
+      as :func:`~urllib.request.urlopen` would normally be used in a context 
manager.
 
 .. function:: aclosing(thing)
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to