https://github.com/python/cpython/commit/d6f4fb867a16fb99a413fb2e9f6b473e97cf48b2 commit: d6f4fb867a16fb99a413fb2e9f6b473e97cf48b2 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: encukou <[email protected]> date: 2026-01-27T11:39:20+01:00 summary:
[3.13] gh-142119: Clarify that one `contextvars.Token` can only reset once in a lifetime (GH-143693) (GH-144267) (cherry picked from commit 487bd2dea538e36cb620dd9e0f298d731b9ede8a) Co-authored-by: Bartosz Sławecki <[email protected]> files: M Doc/library/contextvars.rst diff --git a/Doc/library/contextvars.rst b/Doc/library/contextvars.rst index 2b1fb9fdd29cd8..c34f439282eb7f 100644 --- a/Doc/library/contextvars.rst +++ b/Doc/library/contextvars.rst @@ -93,13 +93,15 @@ Context Variables # After the reset call the var has no value again, so # var.get() would raise a LookupError. + The same *token* cannot be used twice. + .. class:: Token *Token* objects are returned by the :meth:`ContextVar.set` method. They can be passed to the :meth:`ContextVar.reset` method to revert the value of the variable to what it was before the corresponding - *set*. + *set*. A single token cannot reset a context variable more than once. .. attribute:: Token.var _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
