[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-34793: Drop old-style context managers in asyncio.locks #17533

Merged
merged 3 commits into from Feb 1, 2020
+50 −223

Conversation

Copy link
Contributor

asvetlov commented Dec 9, 2019

* ``with (await asyncio.lock):`` and ``with (yield from asyncio.lock):`` statements are
not longer supported, use ``async with lock`` instead. The same is correct for
``asyncio.Condition`` and ``asyncio.Semaphore``.
(Contributed by Andrew Svetlov in :issue:`34793`.)

This comment has been minimized.

Copy link

1st1 Dec 9, 2019

Member

Please also replace the deprecation warning with changedversion in https://docs.python.org/3/library/asyncio-sync.html#boundedsemaphore

This comment has been minimized.

Copy link

asvetlov Dec 10, 2019

Author Contributor

Done



class _ContextManagerMixin:
def __enter__(self):
raise RuntimeError(
'"yield from" should be used as context manager expression')

This comment has been minimized.

Copy link

1st1 Dec 9, 2019

Member

Should we keep this? We can change the error message to say that async with should be used...

This comment has been minimized.

Copy link

asvetlov Dec 10, 2019

Author Contributor

I think the motivation was emphasizing that context managers were supported but in a slightly unusual way: with (yield from lock):; bare with lock: was forbidden.

After switching to async with lock: everything becomes clear: with is not supported in any form for the sake of async with. The error message is standard and well-known: AttributeError: __enter__. I think we shouldn't replace the default behavior.

Maybe the standard text can be improved globally, but it is another story, I guess.

asvetlov added 2 commits Dec 10, 2019
asvetlov merged commit 90d9ba6 into python:master Feb 1, 2020
9 checks passed
9 checks passed
Docs
Details
Windows (x86)
Details
Windows (x64)
Details
macOS
Details
Ubuntu
Details
Azure Pipelines PR #20200131.15 succeeded
Details
bedevere/issue-number Issue number 34793 found
Details
bedevere/news News entry found in Misc/NEWS.d
continuous-integration/travis-ci/pr The Travis CI build passed
Details
asvetlov deleted the asvetlov:drop-deprecations branch Feb 1, 2020
petdance added a commit to petdance/cpython that referenced this pull request Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants