From 21d335ed9ef6fbb16341809fe224b45a3f41243f Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 15 Oct 1993 13:01:11 +0000 Subject: 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. --- Objects/classobject.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'Objects/classobject.c') diff --git a/Objects/classobject.c b/Objects/classobject.c index 8836bb7a26..c0eb8f1e1b 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; } -- cgit v1.2.1