unicode calls __str__ for acquisition wrapped objects

Bug #719335 reported by Michael Howitz on 2011-02-15
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Acquisition
Fix Released
Undecided
Unassigned

Bug Description

unicode(<some_object>) calls the __unicode__ method of the object
but unicode(<some_aq_wrapped_object>) calls __str__

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.

Michael Howitz (mh-gocept) wrote :

Fix released in 2.13.6.

Changed in acquisition:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers