Title: `iscoroutinefunction` returns False for wrapper functions with `update_wrapper` applied · Issue #100317 · python/cpython · GitHub
Open Graph Title: `iscoroutinefunction` returns False for wrapper functions with `update_wrapper` applied · Issue #100317 · python/cpython
X Title: `iscoroutinefunction` returns False for wrapper functions with `update_wrapper` applied · Issue #100317 · python/cpython
Description: When decorating a async function with a decorator that uses @functools.wraps or update_wrapper inspect.iscoroutinefunction returns False. The following code demonstrates this issue: import functools import inspect async def fn(): pass as...
Open Graph Description: When decorating a async function with a decorator that uses @functools.wraps or update_wrapper inspect.iscoroutinefunction returns False. The following code demonstrates this issue: import functool...
X Description: When decorating a async function with a decorator that uses @functools.wraps or update_wrapper inspect.iscoroutinefunction returns False. The following code demonstrates this issue: import functool...
Opengraph URL: https://github.com/python/cpython/issues/100317
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":" `iscoroutinefunction` returns False for wrapper functions with `update_wrapper` applied","articleBody":"\u003c!--\r\n If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not\r\n the right place to seek help. Consider the following options instead:\r\n\r\n - reading the Python tutorial: https://docs.python.org/3/tutorial/\r\n - posting in the \"Users\" category on discuss.python.org: https://discuss.python.org/c/users/7\r\n - emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list\r\n - searching our issue tracker (https://github.com/python/cpython/issues) to see if\r\n your problem has already been reported\r\n--\u003e\r\n\r\nWhen decorating a `async` function with a decorator that uses `@functools.wraps` or `update_wrapper` \r\n`inspect.iscoroutinefunction` returns False.\r\n\r\nThe following code demonstrates this issue:\r\n```python\r\nimport functools\r\nimport inspect\r\n\r\nasync def fn():\r\n pass\r\n\r\nassert inspect.iscoroutinefunction(fn)\r\n\r\ndef decorator(fn):\r\n def wrapper(*args, **kwargs):\r\n return fn(*args, **kwargs)\r\n return wrapper\r\n\r\nassert not inspect.iscoroutinefunction(decorator(fn))\r\n\r\ndef signature_preserving_decorator(fn):\r\n @functools.wraps(fn)\r\n def wrapper(*args, **kwargs):\r\n return fn(*args, **kwargs)\r\n\r\n return wrapper\r\n\r\nassert inspect.iscoroutinefunction(signature_preserving_decorator(fn))\r\n# AssertionError\r\n```\r\nI would expect the last assert statement to pass\r\n\r\n\u003c!-- Include as many relevant details as possible about the environment you experienced the bug in --\u003e\r\n\r\n- CPython versions tested on: 3.10.8\r\n- Operating system and architecture: Linux 5.19.17-2-MANJARO x86_64 GNU/Linux\r\n\r\n\u003c!--\r\nYou can freely edit this text. Remove any lines you believe are unnecessary.\r\n--\u003e\r\n","author":{"url":"https://github.com/jonasBoss","@type":"Person","name":"jonasBoss"},"datePublished":"2022-12-17T11:31:58.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/100317/cpython/issues/100317"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2106244a-67a9-7c8e-63db-4927b81d5841 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B724:2361CC:26CD426:36ACDA6:69691AA1 |
| html-safe-nonce | 2db6ea73ff21cf0df8c1653601a567d4b051402483042ffb814dee20c07424c0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzI0OjIzNjFDQzoyNkNENDI2OjM2QUNEQTY6Njk2OTFBQTEiLCJ2aXNpdG9yX2lkIjoiMjIxNDUxOTI0NTkyMTM5MzMxMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f4d93c1049ac27ed60617f883e3def67afde985a11cab3f4d11ff0beab0a25c9 |
| hovercard-subject-tag | issue:1501349074 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/100317/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0ea7a4523bf120e5559cc901bf61ab28d58d284a285e97196482b1d7ac7ab80a/python/cpython/issues/100317 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0ea7a4523bf120e5559cc901bf61ab28d58d284a285e97196482b1d7ac7ab80a/python/cpython/issues/100317 |
| og:image:alt | When decorating a async function with a decorator that uses @functools.wraps or update_wrapper inspect.iscoroutinefunction returns False. The following code demonstrates this issue: import functool... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonasBoss |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0e60568924309a021b51adabdce15c2a2f285b556f3130d1a2fa2a5bce11c55f |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd206f7ed6207863172be4a783826e86bd2375c3 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width