Stale entries in MRO cache if MRO contains non-base classes #127773
Labels
3.12
only security fixes
3.13
bugs and security fixes
3.14
bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-bug
An unexpected behavior, bug, or error
Uh oh!
There was an error while loading. Please reload this page.
Bug report
For example the following program fails with either
assert WeirdClass.value == 2
orassert WeirdClass.value == 3
in recent Python versions:Adding intervening calls to
sys _clear_internal_caches()
makes the test pass.AssertionError: assert WeirdClass.value == 2
AssertionError: assert WeirdClass.value == 2
AssertionError: assert WeirdClass.value == 2
AssertionError: assert WeirdClass.value == 3
AssertionError: assert WeirdClass.value == 3
We have code that checks for this case, but it hasn't worked properly in Python 3.10+:
cpython/Objects/typeobject.c
Lines 1107 to 1112 in 5c89adf
We also have a test that partly covers this case, but doesn't detect the bug:
cpython/Lib/test/test_capi/test_type.py
Lines 40 to 66 in 5c89adf
Linked PRs
The text was updated successfully, but these errors were encountered: