[ python-Bugs-1583863 ] __str__ cannot be overridden on unicode-derived classes

SourceForge.net noreply at sourceforge.net
Tue Oct 24 17:57:04 CEST 2006


Bugs item #1583863, was opened at 2006-10-24 15:57
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1583863&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mike K (laughingboy0)
Assigned to: Nobody/Anonymous (nobody)
Summary: __str__ cannot be overridden on unicode-derived classes

Initial Comment:
class S(str):
   def __str__(self): return '__str__ overridden'

class U(unicode):
   def __str__(self): return '__str__ overridden'
   def __unicode__(self): return u'__unicode__ overridden'

s = S()
u = U()

print 's:', s
print "str(s):", str(s)
print 's substitued is "%s"\n' % s
print 'u:', u
print "str(u):", str(u)
print 'u substitued is "%s"' % u

-----------------------------------------------------

s: __str__ overridden
str(s): __str__ overridden
s substitued is "__str__ overridden"

u:
str(u): __str__ overridden
u substitued is ""

Results are identical for 2.4.2 and 2.5c2 (running
under windows).



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1583863&group_id=5470


More information about the Python-bugs-list mailing list