From 3e06faec4fa7e6afc266ca83ebd5444b1ddbc04a Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Sat, 18 Oct 2008 21:33:44 +0000 Subject: Modify ctypes types with 'official' functions. Backport from trunk, snv rev 59943 and 59946. --- Misc/NEWS | 3 +++ Modules/_ctypes/_ctypes.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index a492d46..e62bb7c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -92,6 +92,9 @@ Core and builtins Library ------- +- Assigning methods to ctypes.Structure and ctypes.Union subclasses + after creation of the class does now work correctly. See Issue #1700288. + - Issue #3895: _lsprof could be crashed with an external timer that did not return a float when a Profiler object is garbage collected. diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 51a9cf8..e97f9bb 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 == PyType_Type.tp_setattro(self, key, value)) return -1; if (value && PyString_Check(key) && -- cgit v0.12