classification
Title: contextlib.nullcontext doesn't work with async context managers
Type: enhancement Stage: resolved
Components: asyncio, Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, njs, tomgrin10, yselivanov
Priority: normal Keywords: patch

Created on 2020-08-13 20:58 by tomgrin10, last changed 2020-11-09 13:24 by asvetlov. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21870 merged tomgrin10, 2020-08-13 21:19
Messages (4)
msg375346 - (view) Author: Tom Gringauz (tomgrin10) * Date: 2020-08-13 20:58
`contextlib.nullcontext` cannot be used with async conetext managers, because it implements only `__enter__` and `__exit__`, and doesn't implement `__aenter__` and `__aexit__`.
msg375351 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2020-08-13 21:37
I typically don't like objects that support both `with` and `async with`, but in this case I think that's appropriate. Nathaniel, Andrew, what do you think?
msg375357 - (view) Author: Nathaniel Smith (njs) * (Python committer) Date: 2020-08-13 23:59
It does seem pretty harmless in this case.
msg380582 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2020-11-09 12:34
New changeset a117167d8dc8fa673a4646f509551c7950f824e5 by Tom Gringauz in branch 'master':
bpo-41543: contextlib.nullcontext can fill in for an async context manager (GH-21870)
https://github.com/python/cpython/commit/a117167d8dc8fa673a4646f509551c7950f824e5
History
Date User Action Args
2020-11-09 13:24:59asvetlovsetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.10
2020-11-09 12:34:16asvetlovsetmessages: + msg380582
2020-08-13 23:59:43njssetmessages: + msg375357
2020-08-13 21:37:37yselivanovsetnosy: + njs
messages: + msg375351
2020-08-13 21:19:20tomgrin10setkeywords: + patch
stage: patch review
pull_requests: + pull_request20995
2020-08-13 20:58:48tomgrin10create