[New-bugs-announce] [issue5037] unexpected unicode behavior for proxy objects

Taldor report at bugs.python.org
Fri Jan 23 16:03:31 CET 2009

New submission from Taldor <tinusvl at skynet.be>:

Calling the unicode function on a proxy object, doesn't use the proxi-ed
object's __unicode__ method, but its __str__ method.

>>> class A(object):
...   def __str__(self):
...     return "str"    
...   def __unicode__(self):
...     return "unicode"    
>>> a = A()
>>> unicode(a)
>>> import weakref
>>> b = weakref.proxy(a)
>>> unicode(b)

I expected the last result to be u'unicode'. I did get u'unicode' in
Python 2.5 (but not in 2.6).

components: None
messages: 80416
nosy: Taldor
severity: normal
status: open
title: unexpected unicode behavior for proxy objects
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list