[Python-3000-checkins] r57666 - python/branches/py3k/Lib/io.py
guido.van.rossum
python-3000-checkins at python.org
Wed Aug 29 20:10:09 CEST 2007
Author: guido.van.rossum
Date: Wed Aug 29 20:10:08 2007
New Revision: 57666
Modified:
python/branches/py3k/Lib/io.py
Log:
Insist that the argument to TextIOWrapper.write() is a basestring
instance. This was effectively already the case, but the error
reporting was lousy.
Modified: python/branches/py3k/Lib/io.py
==============================================================================
--- python/branches/py3k/Lib/io.py (original)
+++ python/branches/py3k/Lib/io.py Wed Aug 29 20:10:08 2007
@@ -1093,6 +1093,9 @@
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)
More information about the Python-3000-checkins
mailing list