[Python-checkins] cpython (2.7): Issue #19481: print() of unicode, str or bytearray subclass instance in IDLE
serhiy.storchaka
python-checkins at python.org
Tue Dec 10 09:07:29 CET 2013
http://hg.python.org/cpython/rev/df9596ca838c
changeset: 87870:df9596ca838c
branch: 2.7
parent: 87863:eb1039fe090c
user: Serhiy Storchaka <storchaka at gmail.com>
date: Tue Dec 10 10:04:41 2013 +0200
summary:
Issue #19481: print() of unicode, str or bytearray subclass instance in IDLE
no more hangs.
files:
Lib/idlelib/PyShell.py | 12 ++++++++++--
Misc/NEWS | 6 ++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -1338,8 +1338,16 @@
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)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -68,6 +68,12 @@
- 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
-----
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list