Commit 351ca4af authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #19481: print() of unicode, str or bytearray subclass instance in IDLE

no more hangs.
parent cdfe1b8a
......@@ -1338,8 +1338,16 @@ class PseudoOutputFile(PseudoFile):
def write(self, s):
if self.closed:
raise ValueError("write to closed file")
if not isinstance(s, (basestring, bytearray)):
raise TypeError('must be string, not ' + type(s).__name__)
if type(s) not in (unicode, str, bytearray):
# See issue #19481
if isinstance(s, unicode):
s = unicode.__getslice__(s, None, None)
elif isinstance(s, str):
s = str.__str__(s)
elif isinstance(s, bytearray):
s = bytearray.__str__(s)
else:
raise TypeError('must be string, not ' + type(s).__name__)
return self.shell.write(s, self.tags)
......
......@@ -68,6 +68,12 @@ Library
- Issue #19286: Directories in ``package_data`` are no longer added to
the filelist, preventing failure outlined in the ticket.
IDLE
----
- Issue #19481: print() of unicode, str or bytearray subclass instance in IDLE
no more hangs.
Tests
-----
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment