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
___
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:
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
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
___
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
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
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
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
___
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
___
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
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
Changes by Martijn Pieters m...@python.org:
--
components: +IDLE
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23583
___
___
Python-bugs-list
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
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))
--
14 matches
Mail list logo