-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Behavioral differences between the with-statement and ExitStack.enter_context #144386
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Bug description:
I noticed a behavioral difference between the (async) with statement and
(Async)ExitStack. The with statement correctly recognizes context manager methods (__enter__,__exit__,__aenter__, and__aexit__) even when they are defined via__slots__, whereas(Async)ExitStackdoes not.Furthermore, both (async) with-statement and
(Async)ExitStackdon't suppot those special dunder methods stored in__dict__. You can verify from this repository:https://github.com/gottadiveintopython/invest-context-manager
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs