← 返回首页
`iscoroutinefunction` returns False for wrapper functions with `update_wrapper` applied · Issue #100317 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

iscoroutinefunction returns False for wrapper functions with update_wrapper applied #100317

New issue
New issue

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 assert inspect.iscoroutinefunction(fn) def decorator(fn): def wrapper(*args, **kwargs): return fn(*args, **kwargs) return wrapper assert not inspect.iscoroutinefunction(decorator(fn)) def signature_preserving_decorator(fn): @functools.wraps(fn) def wrapper(*args, **kwargs): return fn(*args, **kwargs) return wrapper assert inspect.iscoroutinefunction(signature_preserving_decorator(fn)) # AssertionError

I would expect the last assert statement to pass

  • CPython versions tested on: 3.10.8
  • Operating system and architecture: Linux 5.19.17-2-MANJARO x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.