diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-08 02:28:11 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-08 02:28:11 (GMT) |
commit | 7b6fc8e19de53fc354144d21b7a644d77ff60410 (patch) | |
tree | 4356e4d7dd4e03a9b2947cdca06d47b96b243303 /Objects | |
parent | c1bdbc316de9a433ced7d26e8cfb3039e0768cbb (diff) | |
download | cpython-7b6fc8e19de53fc354144d21b7a644d77ff60410.zip cpython-7b6fc8e19de53fc354144d21b7a644d77ff60410.tar.gz cpython-7b6fc8e19de53fc354144d21b7a644d77ff60410.tar.bz2 |
Fixed memoryview constructor. It allowed arbitrary keyword arguments. The bug was found by mykhal from #python. I've also added a small test case in the new test_memoryview.py
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/memoryobject.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index f0a45f6..2f177c2 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -69,10 +69,15 @@ PyMemoryView_FromObject(PyObject *base) static PyObject * memory_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds) { - PyObject *obj; - if (!PyArg_UnpackTuple(args, "memoryview", 1, 1, &obj)) return NULL; + PyObject *obj; + static char *kwlist[] = {"object", 0}; - return PyMemoryView_FromObject(obj); + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:memoryview", kwlist, + &obj)) { + return NULL; + } + + return PyMemoryView_FromObject(obj); } |