]> granicus.if.org Git - python/commitdiff
Merged revisions 74316,74335 via svnmerge from
authorGeorg Brandl <georg@python.org>
Thu, 13 Aug 2009 08:35:19 +0000 (08:35 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 13 Aug 2009 08:35:19 +0000 (08:35 +0000)
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
........

Doc/library/codecs.rst
Lib/test/test_memoryio.py
Modules/_io/bytesio.c

index 7218d3af7e19fa39616d0882c2d726296a99381d..b8a8ccc68eddb3420fa2c478c293f4eb92faa078 100644 (file)
@@ -74,7 +74,7 @@ It defines the following functions:
    continue without further notice), ``'xmlcharrefreplace'`` (replace with the
    appropriate XML character reference (for encoding only)),
    ``'backslashreplace'`` (replace with backslashed escape sequences (for
-   encoding only)), ``'surrogateescape'`` (replae with surrogate U+DCxx, see
+   encoding only)), ``'surrogateescape'`` (replace with surrogate U+DCxx, see
    :pep:`383`) as well as any other error handling name defined via
    :func:`register_error`.
 
index 0d044e96ba1523bc1ced69690308bba89f71416b..187adad56cfdf0274eb5fccc764f75a381b1a17e 100644 (file)
@@ -416,6 +416,10 @@ class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
         self.assertEqual(memio.write(a), 10)
         self.assertEqual(memio.getvalue(), buf)
 
+    def test_issue5449(self):
+        buf = self.buftype("1234567890")
+        self.ioclass(initial_bytes=buf)
+        self.assertRaises(TypeError, self.ioclass, buf, foo=None)
 
 class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
     buftype = str
index 767584618fd48246ae1a2546516c6535ed09f404..cafe4a21aa5abbb308b1b3901283ddc6732ce8fa 100644 (file)
@@ -642,9 +642,11 @@ bytesio_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 static int
 bytesio_init(bytesio *self, PyObject *args, PyObject *kwds)
 {
+    char *kwlist[] = {"initial_bytes", NULL};
     PyObject *initvalue = NULL;
 
-    if (!PyArg_ParseTuple(args, "|O:BytesIO", &initvalue))
+    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:BytesIO", kwlist,
+                                     &initvalue))
         return -1;
 
     /* In case, __init__ is called multiple times. */