summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-05-25 09:38:27 (GMT)
committerGuido van Rossum <guido@python.org>1993-05-25 09:38:27 (GMT)
commiteb6b33a837a180221b635331e005f990024bdb30 (patch)
treeea03e645019d8494df1753da7ef42f86559ed5f6 /Objects/classobject.c
parent23301a9467024eb70b654924c3f0a54d76702e47 (diff)
downloadcpython-eb6b33a837a180221b635331e005f990024bdb30.zip
cpython-eb6b33a837a180221b635331e005f990024bdb30.tar.gz
cpython-eb6b33a837a180221b635331e005f990024bdb30.tar.bz2
* classobject.c: in instance_getattr, don't make a method out of a
function found as instance data. * socketmodule.c: added 'flags' argument sendto/recvfrom, rewrite argument parsing in send/recv. * More changes related to access (terminology change: owner instead of class; allow any object as owner; local/global variables are owned by their dictionary, only class/instance data is owned by the class; "from...import *" now only imports objects with public access; etc.)
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 0a6fc7e..8836bb7 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -126,7 +126,7 @@ class_getattr(op, name)
return NULL;
}
if (is_accessobject(v)) {
- v = getaccessvalue(v, getclass());
+ v = getaccessvalue(v, getowner());
if (v == NULL)
return NULL;
}
@@ -157,7 +157,7 @@ class_setattr(op, name, v)
}
ac = dictlookup(op->cl_dict, name);
if (ac != NULL && is_accessobject(ac))
- return setaccessvalue(ac, getclass(), v);
+ return setaccessvalue(ac, getowner(), v);
if (v == NULL) {
int rv = dictremove(op->cl_dict, name);
if (rv < 0)
@@ -207,10 +207,10 @@ issubclass(class, base)
{
int i, n;
classobject *cp;
- if (class == NULL || !is_classobject(class))
- return 0;
if (class == base)
return 1;
+ if (class == NULL || !is_classobject(class))
+ return 0;
cp = (classobject *)class;
n = gettuplesize(cp->cl_bases);
for (i = 0; i < n; i++) {
@@ -363,6 +363,7 @@ instance_getattr(inst, name)
INCREF(inst->in_class);
return (object *)inst->in_class;
}
+ class = NULL;
v = dictlookup(inst->in_dict, name);
if (v == NULL) {
v = class_lookup(inst->in_class, name, &class);
@@ -372,13 +373,13 @@ instance_getattr(inst, name)
}
}
if (is_accessobject(v)) {
- v = getaccessvalue(v, getclass());
+ v = getaccessvalue(v, getowner());
if (v == NULL)
return NULL;
}
else
INCREF(v);
- if (is_funcobject(v)) {
+ if (is_funcobject(v) && class != NULL) {
object *w = newinstancemethodobject(v, (object *)inst,
(object *)class);
DECREF(v);
@@ -403,7 +404,7 @@ instance_setattr(inst, name, v)
}
ac = dictlookup(inst->in_dict, name);
if (ac != NULL && is_accessobject(ac))
- return setaccessvalue(ac, getclass(), v);
+ return setaccessvalue(ac, getowner(), v);
if (v == NULL) {
int rv = dictremove(inst->in_dict, name);
if (rv < 0)