We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4e7e015 commit c7e4a79Copy full SHA for c7e4a79
Lib/test/test_context.py
@@ -570,6 +570,22 @@ def __eq__(self, other):
570
ctx2.run(var.set, object())
571
ctx1 == ctx2
572
573
+ def test_context_eq_reentrant_contextvar_set_in_hash(self):
574
+ var = contextvars.ContextVar("v")
575
+ ctx1 = contextvars.Context()
576
+ ctx2 = contextvars.Context()
577
+
578
+ class ReentrantHash:
579
+ def __hash__(self):
580
+ ctx1.run(lambda: var.set(object()))
581
+ return 0
582
+ def __eq__(self, other):
583
+ return isinstance(other, ReentrantHash)
584
585
+ ctx1.run(var.set, ReentrantHash())
586
+ ctx2.run(var.set, ReentrantHash())
587
+ ctx1 == ctx2
588
589
590
# HAMT Tests
591
0 commit comments