[New-bugs-announce] [issue6241] Better type checking for the arguments of io.StringIO

Alexandre Vassalotti report at bugs.python.org
Mon Jun 8 21:47:02 CEST 2009


New submission from Alexandre Vassalotti <alexandre at peadrop.com>:

The included patch makes type checking of the arguments of StringIO
consistent between pyio and io.

>>> import io
>>> io.StringIO(b"hello")
Traceback (most recent call last):
  ...
ValueError: initial_value must be str or None, not bytes
>>> io.StringIO(newline=b"\n")
<_io.StringIO object at 0x7f93d52953d0>
>>> import _pyio as pyio
>>> pyio.StringIO(newline=b"\n")
Traceback (most recent call last):
  ...
TypeError: illegal newline type: <class 'bytes'>

>>> io.StringIO([])
Traceback (most recent call last):
  ...
ValueError: initial_value must be str or None, not list
>>> pyio.StringIO([])
<_pyio.StringIO object at 0x7f93d4942610>

----------
components: IO, Library (Lib)
files: typecheck_init_stringio.diff
keywords: patch
messages: 89104
nosy: alexandre.vassalotti
priority: normal
severity: normal
stage: patch review
status: open
title: Better type checking for the arguments of io.StringIO
type: behavior
versions: Python 3.1, Python 3.2
Added file: http://bugs.python.org/file14231/typecheck_init_stringio.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6241>
_______________________________________


More information about the New-bugs-announce mailing list