Acquisition wrapped objects do not behave well on unicode call

Michael Howitz <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
Hi,

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.

See the following bin/zopectl debug session:

$ bin/zinstance debug
Starting debugger (the name "app" is bound to the top-level Zope object)
>>> import OFS.SimpleItem
>>> class A(OFS.SimpleItem.SimpleItem):
... def __str__(self): return '__str__ called'
... def __unicode__(self): return '__unicode__ called'
...
>>> a = A()
>>> print unicode(a)
__unicode__ called
>>> print unicode(a.__of__(app))
__str__ called
>>> print type(a.__of__(app))
<type 'Acquisition.ImplicitAcquisitionWrapper'>

This happens for Python 2.6 and 2.7 on Zope 2.13.4.

Is there a suggested work around?

P.S.: I also filed a bug report: https://bugs.launchpad.net/acquisition/+bug/719335 


Yours sincerely,
-- 
Michael Howitz · [email protected] · software developer
gocept gmbh & co. kg · forsterstraße 29 · 06112 halle (saale) · germany
http://gocept.com · tel +49 345 1229889 8 · fax +49 345 1229889 1
Zope and Plone consulting and development

_______________________________________________
Zope-Dev maillist  -  [email protected]
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 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.