Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-94912: deprecate asyncio.iscoroutinefunction when it behaves differently to inspect.iscoroutinefunction#94923
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Lib/asyncio/tasks.py Outdated
graingertJul 17, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this will insist on objects being real awaitables rather than virtual awaitables - eg:
importasyncio.tasksimportcollections.abcimportunittest.mock@collections.abc.Awaitable.registerclasssleep_0:def__init__(self):self.__await__=lambda:iter((None, ))asyncdef_wrap_awaitable(awaitable):returnawaitawaitableasyncdefamain():awaitasyncio.ensure_future(sleep_0())# this works currently but with the new code:withunittest.mock.patch("asyncio.tasks._wrap_awaitable",new=_wrap_awaitable):awaitasyncio.ensure_future(sleep_0())# it will breakasyncio.run(amain())
Lib/unittest/mock.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this is to fix#94924
Lib/asyncio/coroutines.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'll need to do a doc change for this too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
cc@hugovk for removals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Please could you add it to a 3.14 section likehttps://docs.python.org/3.12/whatsnew/3.12.html#pending-removal-in-python-3-13 ?
And add a.. deprecated-removed:: 3.12 3.14 to the function in its module rst page.
graingertJul 18, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@hugovk asyncio.iscoroutinefunction's module rst page was already removed:https://github.com/python/cpython/pull/26369/files#diff-5e9a5bb933b1bd1d6092f7e5adb5c06da7a6792e0597f55f911245acacfce7a7L1025
(oops maybe I shouldn't have approved that PR)
Lib/unittest/mock.py Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is another very subtle change - before the signature was checked when the function was called - and now the signature is checked when the coro is primed, but I think this is a better behavior and worth it to allowinspect.iscoroutinefunction to work
2f61137 to5402f43Compare
Uh oh!
There was an error while loading.Please reload this page.
asyncio.iscoroutinefunctiona deprecated alias ofinspect.iscoroutinefunctionand removeasyncio.coroutines._is_coroutine#94912