summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-08-09 20:52:03 (GMT)
committerGuido van Rossum <guido@python.org>1996-08-09 20:52:03 (GMT)
commitd8eb1b340f47bdac2141c996b113ad665c0343f2 (patch)
treea36fc5f2c214044d50b18d2ee0837d8fb3265746 /Objects/object.c
parent929f1b83ea8810c66a5e1e9f162d8680463abb0f (diff)
downloadcpython-d8eb1b340f47bdac2141c996b113ad665c0343f2.zip
cpython-d8eb1b340f47bdac2141c996b113ad665c0343f2.tar.gz
cpython-d8eb1b340f47bdac2141c996b113ad665c0343f2.tar.bz2
Support for tp_getattro, tp_setattro (Sjoerd)
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index be40c40..9d8a16b 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -326,6 +326,16 @@ getattr(v, name)
object *v;
char *name;
{
+ if (v->ob_type->tp_getattro != NULL) {
+ object *w, *res;
+ w = newstringobject(name);
+ if (w == NULL)
+ return NULL;
+ res = (*v->ob_type->tp_getattro)(v, w);
+ XDECREF(w);
+ return res;
+ }
+
if (v->ob_type->tp_getattr == NULL) {
err_setstr(AttributeError, "attribute-less object");
return NULL;
@@ -355,6 +365,17 @@ setattr(v, name, w)
char *name;
object *w;
{
+ if (v->ob_type->tp_setattro != NULL) {
+ object *s;
+ int res;
+ s = newstringobject(name);
+ if (s == NULL)
+ return NULL;
+ res = (*v->ob_type->tp_setattro)(v, s, w);
+ XDECREF(s);
+ return res;
+ }
+
if (v->ob_type->tp_setattr == NULL) {
if (v->ob_type->tp_getattr == NULL)
err_setstr(TypeError,