Issue #19481: print() of string subclass instance in IDLE no more hangs.
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 36aff92..176170f 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -1334,8 +1334,11 @@
def write(self, s):
if self.closed:
raise ValueError("write to closed file")
- if not isinstance(s, str):
- raise TypeError('must be str, not ' + type(s).__name__)
+ if type(s) is not str:
+ if not isinstance(s, str):
+ raise TypeError('must be str, not ' + type(s).__name__)
+ # See issue #19481
+ s = str.__str__(s)
return self.shell.write(s, self.tags)
diff --git a/Misc/NEWS b/Misc/NEWS
index e479732..4190158 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -128,6 +128,11 @@
- Issue #19545: Avoid chained exceptions while passing stray % to
time.strptime(). Initial patch by Claudiu Popa.
+IDLE
+----
+
+- Issue #19481: print() of string subclass instance in IDLE no more hangs.
+
Tests
-----