Store ContextVar.name as the original str object (#8682)

* 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
This commit is contained in:
Jeong, YunWon authored and GitHub committed 2026-09-10 13:46:20 +09:00
1 parent 2fc2479f72
commit 5afe140abd
3 files changed
+120 -21

No files matched your search

-1
View File
@@ -163,7 +163,6 @@ class ContextTest(unittest.TestCase):
with self.assertRaises(ZeroDivisionError):
ctx.run(func, 1, 2, a=123)
@unittest.expectedFailure # TODO: RUSTPYTHON
@isolated_context
def test_context_run_4(self):
ctx1 = contextvars.Context()