This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author uburuntu
Recipients serhiy.storchaka, uburuntu, yselivanov
Date 2020-07-02.19:37:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1593718653.77.0.225340062457.issue41197@roundup.psfhosted.org>
In-reply-to
Content
In this case:

```python3
class A:
    async def close(self):
        pass
    
with closing(A()):
    pass
```

Python will raise `RuntimeWarning: coroutine 'A.close' was never awaited`.

In another case:

```python3
class B:
    def close(self):
        pass
    
async with closing(B()):
    pass
```

Python will raise `TypeError: object NoneType can't be used in 'await' expression` (because it will try to await result of close method).

-----

I was surprised that `contextlib` has no async analogue of this `closing` class, because async scripts often use any kind of closings. Do you think it's better to extract to `asyncclosing` class?
History
Date User Action Args
2020-07-02 19:37:33uburuntusetrecipients: + uburuntu, serhiy.storchaka, yselivanov
2020-07-02 19:37:33uburuntusetmessageid: <1593718653.77.0.225340062457.issue41197@roundup.psfhosted.org>
2020-07-02 19:37:33uburuntulinkissue41197 messages
2020-07-02 19:37:33uburuntucreate