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

2010-04-27 Thread Georg Brandl
Georg Brandl ge...@python.org 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

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

2010-04-27 Thread Eric Smith
Eric Smith e...@trueblade.com 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

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

2010-04-27 Thread Arfrever Frehtes Taifersar Arahesis
Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com added the comment: It's probably a duplicate of issue #1583863. -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8128

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

2010-04-27 Thread Eric Smith
Eric Smith e...@trueblade.com 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

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

2010-03-20 Thread Steven D'Aprano
Steven D'Aprano steve+pyt...@pearwood.info 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:

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

2010-03-13 Thread Eric Smith
Changes by Eric Smith e...@trueblade.com: -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8128 ___ ___ Python-bugs-list mailing

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

2010-03-13 Thread Florent Xicluna
Changes by Florent Xicluna florent.xicl...@gmail.com: -- nosy: +flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8128 ___ ___ Python-bugs-list

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

2010-03-12 Thread Steven D'Aprano
New submission from Steven D'Aprano steve+pyt...@pearwood.info: 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

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

2010-03-12 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- 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 rep...@bugs.python.org