]> granicus.if.org Git - python/commitdiff
Issue 13532: Allow bytearrays to be written also.
authorTerry Jan Reedy <tjreedy@udel.edu>
Mon, 9 Jul 2012 21:57:13 +0000 (17:57 -0400)
committerTerry Jan Reedy <tjreedy@udel.edu>
Mon, 9 Jul 2012 21:57:13 +0000 (17:57 -0400)
Lib/idlelib/PyShell.py
Lib/idlelib/run.py

index 3e23e6c0ad24795b15ca89bd07ab37f50e0cefb6..2bf97a589ec14b16c94877500d5dd192a3bbeae7 100644 (file)
@@ -1265,8 +1265,8 @@ class PseudoFile(object):
         self.encoding = encoding
 
     def write(self, s):
-        if not isinstance(s, basestring):
-            raise TypeError('must be str, not ' + type(s).__name__)
+        if not isinstance(s, (basestring, bytearray)):
+            raise TypeError('must be string, not ' + type(s).__name__)
         self.shell.write(s, self.tags)
 
     def writelines(self, lines):
index 9389a2b0aad1c4d8aacfc2c7f6e36089880ec8bd..67d18810603672f7b13cfeb65d076d741f77c351 100644 (file)
@@ -263,8 +263,8 @@ class _RPCFile(io.TextIOBase):
         return setattr(self.rpc, name, value)
 
     def write(self, s):
-        if not isinstance(s, basestring):
-            raise TypeError('must be str, not ' + type(s).__name__)
+        if not isinstance(s, (basestring, bytearray)):
+            raise TypeError('must be string, not ' + type(s).__name__)
         return self.rpc.write(s)
 
 class MyHandler(rpc.RPCHandler):