Terry J. Reedy added the comment: > [2.7] print() implicitly converts str and bytearray subclasses to str and > left unicode subclasses as is.
This strikes me as possibly a bug in print, but even if that were changed, there is still the issue of sys.stdout.write and pickle. While the patch is a great improvement, it changes the behavior of sys.stdout.write(s), which acts like it calls str.__str__(s) rather than str(s) == s.__str__ --- class S(str): def __str__(self): return 'S: ' + str.__str__(self) s = S('foo') print(s, str(s), str.__str__(s)) import sys sys.stdout.write(s) --- S: foo S: foo foo foo on the console (hang after first line on Idle) I am testing the patch with str(s) changed to str.__str__(s). ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue19481> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com