-
Notifications
You must be signed in to change notification settings - Fork 28
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
_p_repr
drops Acquisition wrappers, even when found on the instance, with the C extensions
#101
Comments
Sorry for coming in late on this. What is rational for Is there some compelling use case here? Would the crazyness around acquisition go away if we didn't do the |
Overriding This only comes up because the improved |
Ha ha, Ah, right, dealing with closed connections... I vaguely remember this being a problem. :) |
I'm very confused. Is something actually defining |
Was this working and broke with some recent PR? |
Acquisition was working for some Zope objects' |
I'll play with this a bit today. Much thanks for your work on this BTW. |
As reported in zopefoundation/Zope#392 , among others. This has caused some pain for the Zope2/4 and Plone folks.
It would seem the obvious cause is that we look for
_p_repr
on the type, not the instance. Changing that makes the pure-Python versions work, but using the C extensions still fails (even when usingPersistence.Persistent
as a base class).This test passes in pure-Python, fails in C when we look for
_p_repr
on the instance (it fails in both when we look on the type):In pure-python, the
print
gives usHi from <class 'ExtensionClass.ImplicitAcquisitionWrapper_Foo'>
, while with C we getHi from <class 'persistent.tests.test_persistence._Persistent_Base.test__p_repr_acquisition.<locals>.Foo'>
Here's what I see that goes wrong.
__repr__
slot asks for the__repr__
object of itself. The intent is to get a callable that's itself wrapped.Wrapper_findattr
PyMethod_Check
, which the wrapper knows how to re-wrap, we actually wind up with a "method-wrapper" (<method-wrapper '__repr__' of Foo object at 0x105273bd8>
). This is the way that C slots are exposed as Python callables. Acquisition doesn't know how to deal with that, and so it gets returned as-is.Persistent.__repr__
with the unwrapped object.It's just not safe to call a C slot with a wrapped object, so it's not clear to me what, if anything, can be done about this.
The text was updated successfully, but these errors were encountered: