From d2bb18b28165ccc6e4678e8046abe6ea7c9677b3 Mon Sep 17 00:00:00 2001 From: Alexandre Vassalotti Date: Wed, 22 Jul 2009 03:07:33 +0000 Subject: Issue #6241: Better type checking for the arguments of io.StringIO. --- Lib/_pyio.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Lib/_pyio.py') diff --git a/Lib/_pyio.py b/Lib/_pyio.py index bbf65bc0b1..5458f990b7 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) -- cgit v1.2.1