Skip to content
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

Type cache can expose previous values during finalization of an object #118492

Open
DinoV opened this issue May 1, 2024 · 0 comments
Open

Type cache can expose previous values during finalization of an object #118492

DinoV opened this issue May 1, 2024 · 0 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@DinoV
Copy link
Contributor

DinoV commented May 1, 2024

Bug report

Bug description:

This should always print True, that is an attribute accessed from a class should match the value that's in the type's mappingproxy:

class X:
    def __del__(inner_self):
        v = C.a
        print(v == C.__dict__['a'])

class C:
    a = X()

# prime the cache
C.a
C.a

# destructor shouldn't be able to see inconsisent state
C.a = X()
C.a = X()

But this prints False because the destructor can be run when the assignment into the type dict occurs, but before the type version is invalidated.

CPython versions tested on:

3.8, CPython main branch

Operating systems tested on:

Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant