From d6f4fb867a16fb99a413fb2e9f6b473e97cf48b2 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 27 Jan 2026 11:39:20 +0100 Subject: [PATCH] [3.13] gh-142119: Clarify that one `contextvars.Token` can only reset once in a lifetime (GH-143693) (GH-144267) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (cherry picked from commit 487bd2dea538e36cb620dd9e0f298d731b9ede8a) Co-authored-by: Bartosz Sławecki --- Doc/library/contextvars.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/contextvars.rst b/Doc/library/contextvars.rst index 2b1fb9fdd29c..c34f439282eb 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 -- 2.47.3