[Python-checkins] r74316 - in python/branches/py3k: Lib/test/test_memoryio.py Modules/_io/bytesio.c

alexandre.vassalotti python-checkins at python.org
Wed Aug 5 01:19:14 CEST 2009


Author: alexandre.vassalotti
Date: Wed Aug 5 01:19:13 2009
New Revision: 74316
Log:
Issue 5449: Fix io.BytesIO to not accept arbitrary keywords
Patch contributed by Erick Tryzelaar.
Modified:
 python/branches/py3k/Lib/test/test_memoryio.py
 python/branches/py3k/Modules/_io/bytesio.c
Modified: python/branches/py3k/Lib/test/test_memoryio.py
==============================================================================
--- python/branches/py3k/Lib/test/test_memoryio.py	(original)
+++ python/branches/py3k/Lib/test/test_memoryio.py	Wed Aug 5 01:19:13 2009
@@ -461,6 +461,11 @@
 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 TextIOTestMixin:
 
Modified: python/branches/py3k/Modules/_io/bytesio.c
==============================================================================
--- python/branches/py3k/Modules/_io/bytesio.c	(original)
+++ python/branches/py3k/Modules/_io/bytesio.c	Wed Aug 5 01:19:13 2009
@@ -759,9 +759,11 @@
 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. */


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /