summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2009-07-22 03:07:33 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2009-07-22 03:07:33 (GMT)
commitd2bb18b28165ccc6e4678e8046abe6ea7c9677b3 (patch)
treeedacc105f2321cdabb57bced5730c7e9d2610dfe /Lib/_pyio.py
parente671fd206b1fe31fdad7a9ec570fffe390ec56ee (diff)
downloadcpython-d2bb18b28165ccc6e4678e8046abe6ea7c9677b3.zip
cpython-d2bb18b28165ccc6e4678e8046abe6ea7c9677b3.tar.gz
cpython-d2bb18b28165ccc6e4678e8046abe6ea7c9677b3.tar.bz2
Issue #6241: Better type checking for the arguments of io.StringIO.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index bbf65bc..5458f99 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1924,8 +1924,10 @@ class StringIO(TextIOWrapper):
# C version, even under Windows.
if newline is None:
self._writetranslate = False
- if initial_value:
+ if initial_value is not None:
if not isinstance(initial_value, str):
+ raise TypeError("initial_value must be str or None, not {0}"
+ .format(type(initial_value).__name__))
initial_value = str(initial_value)
self.write(initial_value)
self.seek(0)