mirror of
https://github.com/python/cpython
synced 2024-09-15 23:06:25 +00:00
Insist that the argument to TextIOWrapper.write() is a basestring
instance. This was effectively already the case, but the error reporting was lousy.
This commit is contained in:
parent
e8a17aafca
commit
dcce8391d1
|
@ -1093,6 +1093,9 @@ def isatty(self):
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue