[issue8128] String interpolation with unicode subclass fails to call __str__

2010-04-27 Thread Eric Smith
Eric Smith added the comment: Yes, that's the cause, thanks for finding that issue. It's actually fixed in 3.1.2, I just hadn't updated my local copy. Closing, since there's nothing to fix here. The 2.6 behavior is correct, and the 3.x behavior that was broken has been fixed. -- reso

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-04-27 Thread Arfrever Frehtes Taifersar Arahesis
Arfrever Frehtes Taifersar Arahesis added the comment: It's probably a duplicate of issue #1583863. -- nosy: +Arfrever ___ Python tracker ___

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-04-27 Thread Eric Smith
Eric Smith added the comment: I agree with Georg. I think 2.x is arguably correct, and 3.1 is broken. It looks like this has already been fixed in 3.2. It's not immediately obvious why that is, I'll have to look at the code more than the quick glance I just gave it. Python 3.1.1+ (release31-

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-04-27 Thread Georg Brandl
Georg Brandl added the comment: In Python 2.x, __unicode__ is called instead of __str__. Whether that's "correct" behavior, I'm not sure, but at least it is consistent with "{}".format(K()). In Python 3.x, __unicode__ doesn't exist and __str__ isn't called; but for "{}".format(K()), it is.

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-03-20 Thread Steven D'Aprano
Steven D'Aprano added the comment: I've assumed that the documentation is correct, and that "%s"%obj should call __str__ for unicode objects as well as everything else. Attached in a test file. -- Added file: http://bugs.python.org/file16595/test_interpolation.py

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-03-13 Thread Florent Xicluna
Changes by Florent Xicluna : -- nosy: +flox ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-03-13 Thread Eric Smith
Changes by Eric Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-03-12 Thread Ezio Melotti
Changes by Ezio Melotti : -- components: +Interpreter Core nosy: +ezio.melotti priority: -> normal stage: -> test needed type: -> behavior versions: +Python 2.7, Python 3.2 -Python 2.5 ___ Python tracker

[issue8128] String interpolation with unicode subclass fails to call __str__

2010-03-12 Thread Steven D'Aprano
New submission from Steven D'Aprano : String interpolation % operates on unicode strings directly without calling the __str__ method. In Python 2.5 and 2.6: >>> class K(unicode): ... def __str__(self): return "Surprise!" ... >>> u"%s" % K("some text") u'some text' but subclasses of str do