Skip to content

Commit 906632a

Browse files
author
georg.brandl
committed
Merged revisions 74316,74335 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ........ r74316 | alexandre.vassalotti | 2009-08-05 01:19:13 +0200 (Mi, 05 Aug 2009) | 4 lines Issue 5449: Fix io.BytesIO to not accept arbitrary keywords Patch contributed by Erick Tryzelaar. ........ r74335 | philip.jenvey | 2009-08-06 22:00:08 +0200 (Do, 06 Aug 2009) | 1 line typo ........ git-svn-id: http://svn.python.org/projects/python/branches/release31-maint@74372 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 23987df commit 906632a

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

Doc/library/codecs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ It defines the following functions:
7474
continue without further notice), ``'xmlcharrefreplace'`` (replace with the
7575
appropriate XML character reference (for encoding only)),
7676
``'backslashreplace'`` (replace with backslashed escape sequences (for
77-
encoding only)), ``'surrogateescape'`` (replae with surrogate U+DCxx, see
77+
encoding only)), ``'surrogateescape'`` (replace with surrogate U+DCxx, see
7878
:pep:`383`) as well as any other error handling name defined via
7979
:func:`register_error`.
8080

Lib/test/test_memoryio.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ def test_bytes_array(self):
416416
self.assertEqual(memio.write(a), 10)
417417
self.assertEqual(memio.getvalue(), buf)
418418

419+
def test_issue5449(self):
420+
buf = self.buftype("1234567890")
421+
self.ioclass(initial_bytes=buf)
422+
self.assertRaises(TypeError, self.ioclass, buf, foo=None)
419423

420424
class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
421425
buftype = str

Modules/_io/bytesio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,9 +642,11 @@ bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
642642
static int
643643
bytesio_init(bytesio *self, PyObject *args, PyObject *kwds)
644644
{
645+
char *kwlist[] = {"initial_bytes", NULL};
645646
PyObject *initvalue = NULL;
646647

647-
if (!PyArg_ParseTuple(args, "|O:BytesIO", &initvalue))
648+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:BytesIO", kwlist,
649+
&initvalue))
648650
return -1;
649651

650652
/* In case, __init__ is called multiple times. */

0 commit comments

Comments
 (0)