summaryrefslogtreecommitdiffstats
path: root/Doc/library/contextlib.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-06-29 08:28:15 (GMT)
committerGitHub <noreply@github.com>2021-06-29 08:28:15 (GMT)
commit6cb145d23f5cf69b6d7414877d142747cd3d134c (patch)
tree0617efcd6911c14a1b8003bb9bee5fc68e521103 /Doc/library/contextlib.rst
parent20a88004bae8ead66a205a125e1fe979376fc3ea (diff)
downloadcpython-6cb145d23f5cf69b6d7414877d142747cd3d134c.zip
cpython-6cb145d23f5cf69b6d7414877d142747cd3d134c.tar.gz
cpython-6cb145d23f5cf69b6d7414877d142747cd3d134c.tar.bz2
bpo-44471: Change error type for bad objects in ExitStack.enter_context() (GH-26820)
A TypeError is now raised instead of an AttributeError in ExitStack.enter_context() and AsyncExitStack.enter_async_context() for objects which do not support the context manager or asynchronous context manager protocols correspondingly.
Diffstat (limited to 'Doc/library/contextlib.rst')
-rw-r--r--Doc/library/contextlib.rst8
1 files changed, 8 insertions, 0 deletions
diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst
index c9065be..7ac3856 100644
--- a/Doc/library/contextlib.rst
+++ b/Doc/library/contextlib.rst
@@ -515,6 +515,10 @@ Functions and classes provided:
These context managers may suppress exceptions just as they normally
would if used directly as part of a :keyword:`with` statement.
+ ... versionchanged:: 3.11
+ Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm*
+ is not a context manager.
+
.. method:: push(exit)
Adds a context manager's :meth:`__exit__` method to the callback stack.
@@ -585,6 +589,10 @@ Functions and classes provided:
Similar to :meth:`enter_context` but expects an asynchronous context
manager.
+ ... versionchanged:: 3.11
+ Raises :exc:`TypeError` instead of :exc:`AttributeError` if *cm*
+ is not an asynchronous context manager.
+
.. method:: push_async_exit(exit)
Similar to :meth:`push` but expects either an asynchronous context manager