FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-144386: Add support for descriptors in ExitStack and AsyncExitStack by serhiy-storchaka · Pull Request #144420 · python/cpython · GitHub

Repository navigation

gh-144386: Add support for descriptors in ExitStack and AsyncExitStack - #144420

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:exit-stack-descriptors
Feb 4, 2026
Merged

serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:exit-stack-descriptors

Conversation

serhiy-storchaka commented Feb 3, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

__enter__(), __exit__(), __aenter__(), and __aexit__() can now be arbitrary descriptors, not only normal methods, for consistency with the "with" and "async with" statements.

…itStack

__enter__(), __exit__(), __aenter__(), and __aexit__() can now be
arbitrary descriptors, not only normal methods, for consistency with the
"with" and "async with" statements.

ncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The general approach looks right to me, but is it feasible to avoid adding the dependency on the inspect module by moving that helper function somewhere lower in the import stack?

Comment thread Lib/contextlib.py Outdated

ncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

In the absence of a Python binding for the actual special method lookup logic, the lazy import looks like a reasonable mitigation to me.

serhiy-storchaka merged commit f73d2e7 into python:main Feb 4, 2026
51 checks passed
serhiy-storchaka deleted the exit-stack-descriptors branch February 4, 2026 11:24
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
…itStack (python#144420)

__enter__(), __exit__(), __aenter__(), and __aexit__() can now be
arbitrary descriptors, not only normal methods, for consistency with the
"with" and "async with" statements.
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
…itStack (python#144420)

__enter__(), __exit__(), __aenter__(), and __aexit__() can now be
arbitrary descriptors, not only normal methods, for consistency with the
"with" and "async with" statements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL