diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-01-14 00:22:44 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-01-14 00:22:44 (GMT) |
commit | 08ccf202e606a066668f4ef85df9a9c0d07e1ba1 (patch) | |
tree | 391a2f89a2d8c159991ac03ad2bd78a93db68311 /Modules | |
parent | d1c131a6e30f7777fe65f6b4fa910150f647b5f5 (diff) | |
download | cpython-08ccf202e606a066668f4ef85df9a9c0d07e1ba1.zip cpython-08ccf202e606a066668f4ef85df9a9c0d07e1ba1.tar.gz cpython-08ccf202e606a066668f4ef85df9a9c0d07e1ba1.tar.bz2 |
As discussed in issue 1700288:
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.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 2 | ||||
-rw-r--r-- | Modules/_ctypes/stgdict.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 1e0f963..a9eb032 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -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) && diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index d92bdf4..66dfb84 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -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; |