summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1993-10-15 13:01:11 (GMT)
committerGuido van Rossum <guido@python.org>1993-10-15 13:01:11 (GMT)
commit21d335ed9ef6fbb16341809fe224b45a3f41243f (patch)
treecbae924f55ae38b4ab599b592c8b2d9c2b98cd25 /Objects
parentcbaddb52aed1076db123e81529781985b2386181 (diff)
downloadcpython-21d335ed9ef6fbb16341809fe224b45a3f41243f.zip
cpython-21d335ed9ef6fbb16341809fe224b45a3f41243f.tar.gz
cpython-21d335ed9ef6fbb16341809fe224b45a3f41243f.tar.bz2
Makefile, import.c: Lance's alternative module search (allow .pyc file
without .py file); Bill's dynamic loading for SunOS using shared libraries. pwdmodule.c (mkgrent): remove DECREF of uninitialized variable. classobject.c (instance_getattr): Fix case when class lookup returns unbound method instead of function.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/classobject.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 8836bb7..c0eb8f1 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -379,11 +379,24 @@ instance_getattr(inst, name)
}
else
INCREF(v);
- if (is_funcobject(v) && class != NULL) {
- object *w = newinstancemethodobject(v, (object *)inst,
- (object *)class);
- DECREF(v);
- v = w;
+ if (class != NULL) {
+ if (is_funcobject(v)) {
+ object *w = newinstancemethodobject(v, (object *)inst,
+ (object *)class);
+ DECREF(v);
+ v = w;
+ }
+ else if (is_instancemethodobject(v)) {
+ object *im_class = instancemethodgetclass(v);
+ /* Only if classes are compatible */
+ if (issubclass((object *)class, im_class)) {
+ object *im_func = instancemethodgetfunc(v);
+ object *w = newinstancemethodobject(im_func,
+ (object *)inst, im_class);
+ DECREF(v);
+ v = w;
+ }
+ }
}
return v;
}