Message205740
> [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). |
|
Date |
User |
Action |
Args |
2013-12-09 21:10:40 | terry.reedy | set | recipients:
+ terry.reedy, tim.peters, kbk, ned.deily, roger.serwy, serhiy.storchaka |
2013-12-09 21:10:40 | terry.reedy | set | messageid: <1386623440.74.0.575446896244.issue19481@psf.upfronthosting.co.za> |
2013-12-09 21:10:40 | terry.reedy | link | issue19481 messages |
2013-12-09 21:10:40 | terry.reedy | create | |
|