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

ContainedProxy providedBy caching broken in 4.4.0 #38

Open
jamadden opened this issue Apr 6, 2020 · 1 comment
Open

ContainedProxy providedBy caching broken in 4.4.0 #38

jamadden opened this issue Apr 6, 2020 · 1 comment

Comments

@jamadden
Copy link
Member

jamadden commented Apr 6, 2020

After 1523b1c, it is no longer necessarily the case that c = ContainedProxy(obj); providedBy(c) is providedBy(c); previously it was.

Whether or not it is true depends on whether obj provides interfaces that overlap with ContainedProxy and which thus have to be removed.

Provides(cls, provided) in zope.interface does caching using (cls, provided) as the (strongly referenced) cache key. But the descriptor used to implement __provides__ for ContainedProxy calculates provided as a new object: provided = provided - duplicate_interface, and hashing of that object is based on identity.

(If someone keeps alive a reference to providedBy(c), it will also stick around uselessly forever. )

@jamadden
Copy link
Member Author

jamadden commented Apr 6, 2020

Example:

>>> from zope.interface import *
>>> from zope.container.contained import ContainedProxy
>>> from persistent import Persistent

>>> class Foo:  # No overlap
…    pass
>>> c = ContainedProxy(Foo())
>>> providedBy(c) is providedBy(c)
True

>>> c = ContainedProxy(Persistent()) # These overlap
>>> providedBy(c) is providedBy(c)
False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant