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

Regression in 4.9: Subclasses can't use @adapter #168

Closed
jamadden opened this issue May 27, 2021 · 0 comments · Fixed by #169
Closed

Regression in 4.9: Subclasses can't use @adapter #168

jamadden opened this issue May 27, 2021 · 0 comments · Fixed by #169
Labels

Comments

@jamadden
Copy link
Member

Because of the custom metaclass. Previously this code used to work:

>>> import BTrees
>>> from zope.component import adapter
>>> from zope.interface import Interface
>>> @adapter(Interface)
... class Subclass(BTrees.family64.OO.BTree):
...     pass
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "//zope/component/_declaration.py", line 33, in __call__
    ob.__component_adapts__ = _adapts_descr(self.interfaces)
TypeError: BTrees: cannot set attribute '__component_adapts__' of immutable type 'Subclass'

Apparently there exists code like this in the wild.

@jamadden jamadden added the bug label May 27, 2021
jamadden added a commit that referenced this issue May 27, 2021
This was broken by #166.

Fixes #168. Instead of directly raising the TypeError ourself for an unknown attribute, defer to PyType_Type.tp_setatro if we don't know the attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant