summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-08-12 12:49:46 (GMT)
committerGuido van Rossum <guido@python.org>1994-08-12 12:49:46 (GMT)
commite149fa2a1e34d18497579fff198c7ac2feb19096 (patch)
treec6eff9749f434fad29134aaf48f569bcd7d1afe9 /Include
parente025e31de6973ce6bb7d8ee988683acf9cb9ff92 (diff)
downloadcpython-e149fa2a1e34d18497579fff198c7ac2feb19096.zip
cpython-e149fa2a1e34d18497579fff198c7ac2feb19096.tar.gz
cpython-e149fa2a1e34d18497579fff198c7ac2feb19096.tar.bz2
* Objects/classobject.c, Include/classobject.h: added __getattr__
and __setattr__ support to override getattr(x, name) and setattr(x, name, value) for class instances. This uses a special hack whereby the class is supposed to be static: the __getattr__ and __setattr__ methods are looked up only once and saved in the instance structure for speed
Diffstat (limited to 'Include')
-rw-r--r--Include/classobject.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/Include/classobject.h b/Include/classobject.h
index bd6cc1d..6b1b85b 100644
--- a/Include/classobject.h
+++ b/Include/classobject.h
@@ -30,6 +30,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Class object interface */
+#ifdef WITH_THREAD
+#include "thread.h"
+#else
+#define get_thread_ident() 1L
+#endif
+
/* Revealing some structures (not for general use) */
typedef struct {
@@ -43,6 +49,12 @@ typedef struct {
OB_HEAD
classobject *in_class; /* The class object */
object *in_dict; /* A dictionary */
+ object *in_getattr; /* A method or NULL */
+ object *in_setattr; /* A method or NULL */
+ long in_ident; /* A thread ident or 0 */
+#ifdef WITH_THREAD
+ type_lock *in_lock; /* A lock or NULL */
+#endif
} instanceobject;
extern typeobject Classtype, Instancetype, Instancemethodtype;