summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-01-16 19:37:33 (GMT)
committerThomas Heller <theller@ctypes.org>2008-01-16 19:37:33 (GMT)
commit02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152 (patch)
tree8cbd8dd33cbe3bcad02e4adf86b57e3a27788d7a /Modules
parent902d30752fa79fa787114b3f2cde37513909bc57 (diff)
downloadcpython-02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152.zip
cpython-02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152.tar.gz
cpython-02ec289f3e16ee6b00ecf7ec8f8e0f2a3e1ad152.tar.bz2
Raise a TypeError if conflicting positional and named arguments are
passed to a Structure or Union constructor.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 1ff8e12..8c66194 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3578,6 +3578,21 @@ Struct_init(PyObject *self, PyObject *args, PyObject *kwds)
return IBUG("_fields_[i][0] failed");
}
+ if (kwds && PyDict_GetItem(kwds, name)) {
+ char *field = PyString_AsString(name);
+ if (field == NULL) {
+ PyErr_Clear();
+ field = "???";
+ }
+ PyErr_Format(PyExc_TypeError,
+ "duplicate values for field %s",
+ field);
+ Py_DECREF(pair);
+ Py_DECREF(name);
+ Py_DECREF(fields);
+ return -1;
+ }
+
val = PyTuple_GET_ITEM(args, i);
if (-1 == PyObject_SetAttr(self, name, val)) {
Py_DECREF(pair);