Commit c378f574 authored by Guido van Rossum's avatar Guido van Rossum

Insist that the argument to TextIOWrapper.write() is a basestring

instance.  This was effectively already the case, but the error
reporting was lousy.
parent 6d4d04c4
......@@ -1093,6 +1093,9 @@ class TextIOWrapper(TextIOBase):
def write(self, s: str):
if self.closed:
raise ValueError("write to closed file")
if not isinstance(s, basestring):
raise TypeError("can't write %s to text stream" %
s.__class__.__name__)
haslf = "\n" in s
if haslf and self._writetranslate and self._writenl != "\n":
s = s.replace("\n", self._writenl)
......
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