changeset: 87870:df9596ca838c branch: 2.7 parent: 87863:eb1039fe090c user: Serhiy Storchaka date: Tue Dec 10 10:04:41 2013 +0200 files: Lib/idlelib/PyShell.py Misc/NEWS description: Issue #19481: print() of unicode, str or bytearray subclass instance in IDLE no more hangs. diff -r eb1039fe090c -r df9596ca838c Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Tue Dec 10 01:23:22 2013 +0100 +++ b/Lib/idlelib/PyShell.py Tue Dec 10 10:04:41 2013 +0200 @@ -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 -r eb1039fe090c -r df9596ca838c Misc/NEWS --- a/Misc/NEWS Tue Dec 10 01:23:22 2013 +0100 +++ b/Misc/NEWS Tue Dec 10 10:04:41 2013 +0200 @@ -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 -----