You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug fix to prevent io.BytesIO from accepting arbitrary keyword arguments #49699
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.
Activity
erickt commentedon Mar 8, 2009
I noticed that it was possible to specify arbitrary arguments to
io.BytesIO:
But io.StringIO doesn't:
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.
avassalotti commentedon Aug 4, 2009
Committed in r74316.
Thanks!