On Tue, Feb 15, 2011 at 2:35 PM, Michael Howitz <m...@gocept.com> wrote:
> When I have an acquisition wrapped object, e. g. my_object and call:
>
>>>> unicode(my_object)
>
> The method __str__ of my_object is called even when it has an __unicode__ 
> method.

Acquisition wrappers only fill the tp_repr and tp_str slot and as far
as I can tell there's no tp_unicode slot in PyObject_HEAD_INIT.

So I'm not sure how to add the C equivalent of a __unicode__ to the
Wrappertype and XaqWrappertype PyExtensionClasses. It would probably
have to do a lookup for a __unicode__ method on the wrapped instance,
call it if it exists and otherwise call its own __str__ - essentially
duplicating the logic of the string type.

My C-fu is too weak to attempt this. The workaround is to call
unicode(aq_base(my_object)).

Hanno
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )

Reply via email to