[issue37398] contextlib.ContextDecorator decorating async functions

John Belmonte report at bugs.python.org
Thu Jul 25 02:22:48 EDT 2019


John Belmonte <john at neggie.net> added the comment:

I was caught by this again, indirectly via @contextmanager.

If I define a non-async context manager using @contextmanager, I expect the decorator support to work on async functions.  I.e. the following should be equivalent:

```
async def foo():
    with non_async_cm:
        ...
```
```
@non_async_cm
async def foo():
    ...
```

Not only does the 2nd case not work, but the decorator is (effectively) silently ignored :(

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37398>
_______________________________________


More information about the Python-bugs-list mailing list