diff options
author | Guido van Rossum <guido@python.org> | 2007-08-29 18:10:08 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-08-29 18:10:08 (GMT) |
commit | dcce8391d1c76ebc6f81a0d22224e29f0a9f0c49 (patch) | |
tree | dec3d8ddc652ce9d066d979cf967bc60bcc83f32 | |
parent | e8a17aafca9c38aa5b74bc9066b6c7e867f25567 (diff) | |
download | cpython-dcce8391d1c76ebc6f81a0d22224e29f0a9f0c49.zip cpython-dcce8391d1c76ebc6f81a0d22224e29f0a9f0c49.tar.gz cpython-dcce8391d1c76ebc6f81a0d22224e29f0a9f0c49.tar.bz2 |
Insist that the argument to TextIOWrapper.write() is a basestring
instance. This was effectively already the case, but the error
reporting was lousy.
-rw-r--r-- | Lib/io.py | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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) |