mariojonke · GitHub

Bug report

Bug description:

Accessing the Token.MISSING class var from the contextvars module within a subinterpreter raises an AttributeError. E.g. the following script:

import contextvars
from concurrent.interpreters import create, get_current
print(get_current(), contextvars.Token, getattr(contextvars.Token, "MISSING", None))
ip1 = create()
ip1.exec("""
import contextvars
from concurrent.interpreters import get_current

print(get_current(), contextvars.Token, getattr(contextvars.Token, "MISSING", "'doesn't exist'"))
""")

outputs

Interpreter(0) <class '_contextvars.Token'> <Token.MISSING>
Interpreter(1) <class '_contextvars.Token'> 'doesn't exist'

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗