gh-127773: Disable attribute cache on incompatible MRO entries (GH-127924)

This commit is contained in:
Petr Viktorin 2025-01-13 14:10:41 +01:00 committed by GitHub
parent 76ffaef729
commit aa6579cb60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 50 additions and 2 deletions

View file

@ -254,6 +254,33 @@ Test failures in looking up the __prepare__ method work.
[...]
test.test_metaclass.ObscureException
Test setting attributes with a non-base type in mro() (gh-127773).
>>> class Base:
... value = 1
...
>>> class Meta(type):
... def mro(cls):
... return (cls, Base, object)
...
>>> class WeirdClass(metaclass=Meta):
... pass
...
>>> Base.value
1
>>> WeirdClass.value
1
>>> Base.value = 2
>>> Base.value
2
>>> WeirdClass.value
2
>>> Base.value = 3
>>> Base.value
3
>>> WeirdClass.value
3
"""
import sys