Re: Acquisition wrapped objects do not behave well on unicode call

David Glick <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
On 3/1/11 11:57 AM, Christian Zagrodnick wrote:
> This change introduces a regression when calling unicode on wrapped
>>> objects that implement __str__ but not __unicode__. Essentially it is
>>> now doing the equivalent of str(aq_base(obj)) ... __str__ used to get a
>>> wrapped object as 'self', but now it is unwrapped.
>>>
>>> Here's a failing test that can be added to Acquisition's TestUnicode
>>> test case to demonstrate the issue:
>>>
>>> def test_str_fallback_is_still_wrapped(self):
>>> class A(Acquisition.Implicit):
>>> def __str__(self):
>>> return str(len(Acquisition.aq_chain(self)))
>>> wrapped = A().__of__(A())
>>> self.assertEqual(u'2', unicode(wrapped))
>>>
>>> This is currently causing some regressions in Plone tests.
>> I'll have a look at it. Thanks for spotting that.
> Fixed in r120651 (trunk)
>
> - Fixed bug: When an object did not implement ``__unicode__``, calling
>    ``unicode(wrapped)`` was calling ``__str__`` with an unwrapped ``self``.
>
> Is the situation with Plone better now?
>
Yes, this fixes the test failures we were seeing before. Thanks!
David


----------		
David Glick
 Web Developer
 [email protected]
 206.286.1235x32

Groundwire: You Are Connected		
 http://groundwire.org		

Online tools and strategies for the environmental movement.  Sign up for Groundwire News!
 http://groundwire.org/email-capture


_______________________________________________
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.