Closed
Description
A TypeError is now raised instead of an AttributeError in contextlib.ExitStack.enter_context() and contextlib.AsyncExitStack.enter_async_context() for objects which do not support the context manager or asynchronous context manager protocols correspondingly. (Contributed by Serhiy Storchaka in bpo-44471.)
however this is only to match the change in behaviour of the async with
and with
statements in 3.11:
A TypeError is now raised instead of an AttributeError in with and async with statements for objects which do not support the context manager or asynchronous context manager protocols correspondingly. (Contributed by Serhiy Storchaka in bpo-12022.)
so would need conditional checking.
perhaps:
if sys.version_info >= (3, 11):
from contextlib import ExitStack, AsyncExitStack
else:
class ExitStack(...):
...
class AsyncExitStack(...):
...
would be best?
Metadata
Metadata
Assignees
Labels
No labels