| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…"async for" They use special method lookup for special methods.
|
I happened to notice that there might be a small point to adjust. The updated equivalent code manager.__enter__ could look up __enter__ in the instance attributes, but the with-statement does not. import sys
class CM:
def __init__(self):
def __enter__():
pass
def __exit__(*exc_details):
pass
self.__enter__ = __enter__
self.__exit__ = __exit__
# Not works: TypeError: 'CM' object does not support the context manager protocol (missed __exit__ method)
with CM():
pass
# Works
manager = CM()
enter = manager.__enter__
exit_ = manager.__exit__
value = enter()
hit_except = False
try:
TARGET = value
except:
hit_except = True
if not exit(*sys.exc_info()):
raise
finally:
if not hit_except:
exit_(None, None, None) |
Sorry, something went wrong.
|
Yes, this is what the added note for. |
Sorry, something went wrong.
|
Oops, I missed that. |
Sorry, something went wrong.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
Sorry, something went wrong.
…"async for" (pythonGH-144472) They use special method lookup for special methods. (cherry picked from commit 9e8fa2d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…"async for" (pythonGH-144472) They use special method lookup for special methods. (cherry picked from commit 9e8fa2d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
GH-144945 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
|
GH-144946 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
…"async for" (pythonGH-144472) They use special method lookup for special methods.
…"async for" (pythonGH-144472) They use special method lookup for special methods.
| Back | FazBrowse Home | New Git URL |
They use special method lookup for special methods.
📚 Documentation preview 📚: https://cpython-previews--144472.org.readthedocs.build/