bpo-32436: Implement PEP 567 by 1st1 · Pull Request #5027 · python/cpython (original) (raw)
Oh, this is a real bug, thanks so much for finding it!
Funny enough, I initially got this right, and was using val_or_node == val
. At sometime I decided to review/document hamt.c and changed it to PyObject_RichCompareBool
without giving it too much thought.
Anyways, I'll fix the HAMT and it will also fix the fatal error you saw. That error is interesting on its own. What happened is that PyContextVar_Set
caches a borrowed ref to the last value set. Because you were setting another empty list object to the variable, it wasn't really stored (because of the bug in hamt.c
), so we stored a borrowed reference to an object that was about to be GCed.