summaryrefslogtreecommitdiffstats
path: root/Objects
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
parent929f1b83ea8810c66a5e1e9f162d8680463abb0f (diff)
downloadcpython-d8eb1b340f47bdac2141c996b113ad665c0343f2.zip
cpython-d8eb1b340f47bdac2141c996b113ad665c0343f2.tar.gz
cpython-d8eb1b340f47bdac2141c996b113ad665c0343f2.tar.bz2
Support for tp_getattro, tp_setattro (Sjoerd)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c6
-rw-r--r--Objects/mappingobject.c6
-rw-r--r--Objects/object.c21
3 files changed, 33 insertions, 0 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index f655828..605c6db 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -769,6 +769,9 @@ getattro(v, name)
object *v;
object *name;
{
+ if (v->ob_type->tp_getattro != NULL)
+ return (*v->ob_type->tp_getattro)(v, name);
+
if (name != last_name_object) {
XDECREF(last_name_object);
INCREF(name);
@@ -784,6 +787,9 @@ setattro(v, name, value)
object *name;
object *value;
{
+ if (v->ob_type->tp_setattro != NULL)
+ return (*v->ob_type->tp_setattro)(v, name, value);
+
if (name != last_name_object) {
XDECREF(last_name_object);
INCREF(name);
diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c
index f655828..605c6db 100644
--- a/Objects/mappingobject.c
+++ b/Objects/mappingobject.c
@@ -769,6 +769,9 @@ getattro(v, name)
object *v;
object *name;
{
+ if (v->ob_type->tp_getattro != NULL)
+ return (*v->ob_type->tp_getattro)(v, name);
+
if (name != last_name_object) {
XDECREF(last_name_object);
INCREF(name);
@@ -784,6 +787,9 @@ setattro(v, name, value)
object *name;
object *value;
{
+ if (v->ob_type->tp_setattro != NULL)
+ return (*v->ob_type->tp_setattro)(v, name, value);
+
if (name != last_name_object) {
XDECREF(last_name_object);
INCREF(name);
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,