]> granicus.if.org Git - python/commitdiff
As discussed in issue 1700288:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 14 Jan 2008 00:22:44 +0000 (00:22 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 14 Jan 2008 00:22:44 +0000 (00:22 +0000)
ctypes takes some liberties when creating python types: it modifies the types'
__dict__ directly, bypassing all the machinery of type objects which deal with
special methods.  And this broke recent optimisations of method lookup.
Now we try to modify the type with more "official" functions.

Modules/_ctypes/_ctypes.c
Modules/_ctypes/stgdict.c

index 1e0f9632f55755a98d77fe69fa1bd5f6384a7abb..a9eb032b0106b2656823d85189950bf0213baca9 100644 (file)
@@ -410,7 +410,7 @@ static int
 StructType_setattro(PyObject *self, PyObject *key, PyObject *value)
 {
        /* XXX Should we disallow deleting _fields_? */
-       if (-1 == PyObject_GenericSetAttr(self, key, value))
+       if (-1 == Py_TYPE(self)->tp_base->tp_setattro(self, key, value))
                return -1;
        
        if (value && PyString_Check(key) &&
index d92bdf4f0dccc321e669a4435d949abf04da46f0..66dfb8417fc2a5a7e50dc068fb8f2a27b5a19d7a 100644 (file)
@@ -470,7 +470,7 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
                        Py_DECREF(pair);
                        return -1;
                }
-               if (-1 == PyDict_SetItem(realdict, name, prop)) {
+               if (-1 == PyObject_SetAttr(type, name, prop)) {
                        Py_DECREF(prop);
                        Py_DECREF(pair);
                        return -1;