[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583 ___

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-24 Thread Roundup Robot
Roundup Robot added the comment: New changeset cd9e4f73b5ce by Serhiy Storchaka in branch '2.7': Issue #23583: Fixed writing unicode to standard output stream in IDLE. https://hg.python.org/cpython/rev/cd9e4f73b5ce New changeset 0c72cdf3ff22 by Serhiy Storchaka in branch '2.7': Issue #23583:

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I can propose two ways to fix this: s = unicode.__getslice__(s, 0, unicode.__len__(s)) and s = unicode.__getitem__(s, slice(None)) -- ___ Python tracker rep...@bugs.python.org

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Just len() doesn't work when the subclass overrides __len__. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583 ___

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
Martijn Pieters added the comment: I like the unicode.__getitem__(s, slice(None)) approach, it has the advantage of not having to rely on len(s). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: I don't see what you have in mind. Translating my example class S(str): def __str__(self): return 'S: ' + str.__str__(self) to class U(unicode): def __unicode__(self): return u'U: ' + unicode.__unicode__(self) does not work because

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: What about just 's = unicode(s)'? The doc says object.__unicode__(self) Called to implement unicode() built-in; should return a Unicode object. When this method is not defined, string conversion is attempted, and the result of string conversion is

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See example in msg205740. The same works with overridden __unicode__. I'm writing tests now. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583 ___

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file38338/idle_test_io-3.5.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583 ___

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: does not work because there is no unicode.__unicode__. Yes, this is why unicode.__getslice__ or unicode.__getitem__ should be used. Here is a patch for 2.7 that fixes this issue and adds tests for PseudoOutputFile and PseudoInputFile. Tests should be

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
New submission from Martijn Pieters: This is a regression or recurrence of issue #19481. To reproduce, create a subclass of unicode and try and print an instance of that class: class Foo(unicode): pass print Foo() results in a traceback: Traceback (most recent call last): File

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
Changes by Martijn Pieters m...@python.org: -- components: +IDLE ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583 ___ ___ Python-bugs-list

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- components: +Unicode nosy: +ezio.melotti, haypo, ned.deily, serhiy.storchaka, terry.reedy type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23583

[issue23583] IDLE: printing unicode subclasses broken (again)

2015-03-04 Thread Martijn Pieters
Martijn Pieters added the comment: Proposed fix, replace line 1352-1353 in PseudoOutputFile.write(): if isinstance(s, unicode): s = unicode.__getslice__(s, None, None) with if isinstance(s, unicode): s = unicode.__getslice__(s, 0, len(s)) --