mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #6241: Better type checking for the arguments of io.StringIO.
This commit is contained in:
parent
e671fd206b
commit
d2bb18b281
3 changed files with 38 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue