[issue5449] bug fix to prevent io.BytesIO from accepting arbitrary keyword arguments

Erick Tryzelaar report at bugs.python.org
Mon Mar 9 00:53:00 CET 2009


New submission from Erick Tryzelaar <idadesub at users.sourceforge.net>:

I noticed that it was possible to specify arbitrary arguments to 
io.BytesIO:

>>> io.BytesIO(b'foo', foo=1)
<_io.BytesIO object at 0x430150>

But io.StringIO doesn't:

>>> io.StringIO('foo', foo=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'foo' is an invalid keyword argument for this function

So, I've attached a little patch that uses the same technique 3.1a1 uses 
to parse the arguments. One thing to be aware of is that I named the 
kwarg "intial_bytes" just like http://docs.python.org/3.0/library/io.html#io.BytesIO instead of 
"inital_value" like io.StringIO. I'm not sure if it'd be desirable to be 
consistent between the two.

----------
components: Library (Lib)
files: 0001-Fix-io.BytesIO-to-not-accept-arbitrary-keywords.patch
keywords: patch
message_count: 1.0
messages: 83337
nosy: erickt
nosy_count: 1.0
severity: normal
status: open
title: bug fix to prevent io.BytesIO from accepting arbitrary keyword arguments
type: behavior
versions: Python 3.0, Python 3.1
Added file: http://bugs.python.org/file13271/0001-Fix-io.BytesIO-to-not-accept-arbitrary-keywords.patch

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


More information about the Python-bugs-list mailing list