* Prevent ContextVar cache hits after Context address reuse
Give each Context, including copies, a non-reused cache identity instead
of using its heap address. Disable cache hits if the identity counter
saturates. This prevents an empty Context from reading a destroyed
Context's cached value while preserving existing locking and drop order.
Assisted-by: Codex:model-version-unavailable
* Cover ContextVar reads after context destruction
Exercise fresh and copied contexts with variable defaults, explicit defaults and missing values. The repeated lifecycle check complements canonical context tests without relying on a fixed allocator address-reuse count.
Assisted-by: Codex:model-version-unavailable
* Move ContextVar cache regression into the contextvars snippet
Preserve the fresh and copied Context lifetime checks, defaults and missing-value assertions while removing the redundant Rust interpreter wrapper.
Assisted-by: Codex:model-version-unavailable
* fix(contextvars): isolate context stack per interpreter and thread on VirtualMachine
* style: format and sort imports in extra_tests/snippets/stdlib_contextvars.py
Assisted-by: Antigravity:Gemini-3.8-Flash
* Store ContextVar.name as the original str object
Keep the constructor argument instead of converting it to a Rust String
so lone surrogates and str subclasses are preserved. Build __repr__
from the name and default reprs.
Assisted-by: Grok:4.6
* Compare Context objects by their variable maps
Implement Context ==/!= from the mapping contents and mark Context
unhashable. Snapshot the map before value equality so re-entrant
ContextVar.set during __eq__ cannot deadlock.
Enable test_context.ContextTest.test_context_run_4.
Assisted-by: Grok:4.6