Skip to content

bpo-28866: Add regression test #17573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5637,6 +5637,30 @@ def mro(cls):
class A(metaclass=M):
pass

def test_custom_mro_doesnt_cache(self):
"""Regression test for https://bugs.python.org/issue28866 """

class Foo:
pass

class Meta(type):
def mro(cls):
return (cls, Foo, object)

def __setattr__(cls, name, value):
setattr(Foo, name, value)

proxy = Meta('FooProxy', (), {})

proxy.x = 300
proxy.x # try to populate the cache
proxy.x = 0

# Before the fix, this retreived the old value (300) from the cache
# (That value could even be garbage-collected, if there are no other
# references to it.)
self.assertEqual(proxy.x, 0)


def test_main():
# Run all local test cases, with PTypesLongInitTest first.
Expand Down