* Lots of small changes related to access.
* Added "access *: ...", made access work for class methods.
* Introduced subclass check: make sure that when calling
  ClassName.methodname(instance, ...), the instance is an instance of
  ClassName or of a subclass thereof (this might break some old code!)
diff --git a/Objects/accessobject.c b/Objects/accessobject.c
index 41790cd..6fd9bd5 100644
--- a/Objects/accessobject.c
+++ b/Objects/accessobject.c
@@ -99,6 +99,15 @@
 	ap->ac_class = class;
 }
 
+int
+hasaccessvalue(op)
+	object *op;
+{	
+	if (!is_accessobject(op))
+		return 0;
+	return ((accessobject *)op)->ac_value != NULL;
+}
+
 object *
 getaccessvalue(op, class)
 	object *op;
@@ -268,7 +277,9 @@
 	char buf[300];
 	classobject *class = (classobject *)ap->ac_class;
 	typeobject *type = ap->ac_type;
-	sprintf(buf, "<access object, class %.100s, type %.100s, mode 0%o>",
+	sprintf(buf,
+	"<access object, value 0x%lx, class %.100s, type %.100s, mode %04o>",
+		(long)(ap->ac_value),
 		class ? getstringvalue(class->cl_name) : "-",
 		type ? type->tp_name : "-",
 		ap->ac_mode);
diff --git a/Objects/classobject.c b/Objects/classobject.c
index e2a5e63..0a6fc7e 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -121,18 +121,24 @@
 		return v;
 	}
 	v = class_lookup(op, name, &class);
-	if (v != NULL) {
-		if (is_accessobject(v))
-			v = getaccessvalue(v, getclass());
-		else if (is_funcobject(v))
-			v = newinstancemethodobject(v, (object *)NULL,
-						    (object *)class);
-		else
-			INCREF(v);
-		return v;
+	if (v == NULL) {
+		err_setstr(AttributeError, name);
+		return NULL;
 	}
-	err_setstr(AttributeError, name);
-	return NULL;
+	if (is_accessobject(v)) {
+		v = getaccessvalue(v, getclass());
+		if (v == NULL)
+			return NULL;
+	}
+	else
+		INCREF(v);
+	if (is_funcobject(v)) {
+		object *w = newinstancemethodobject(v, (object *)NULL,
+						    (object *)class);
+		DECREF(v);
+		v = w;
+	}
+	return v;
 }
 
 static int
@@ -217,12 +223,6 @@
 
 /* Instance objects */
 
-typedef struct {
-	OB_HEAD
-	classobject	*in_class;	/* The class object */
-	object		*in_dict;	/* A dictionary */
-} instanceobject;
-
 static object *instance_getattr PROTO((instanceobject *, char *));
 
 static int
@@ -241,8 +241,11 @@
 	
 	pos = 0;
 	while (mappinggetnext(class->cl_dict, &pos, &key, &value)) {
+		object *v;
 		if (!is_accessobject(value))
 			continue;
+		if (hasaccessvalue(value))
+			continue;
 		ac = dict2lookup(inst->in_dict, key);
 		if (ac != NULL && is_accessobject(ac)) {
 			err_setval(ConflictError, key);
@@ -361,22 +364,27 @@
 		return (object *)inst->in_class;
 	}
 	v = dictlookup(inst->in_dict, name);
-	if (v != NULL) {
-		if (is_accessobject(v))
-			v = getaccessvalue(v, getclass());
-		else
-			INCREF(v);
-		return v;
+	if (v == NULL) {
+		v = class_lookup(inst->in_class, name, &class);
+		if (v == NULL) {
+			err_setstr(AttributeError, name);
+			return NULL;
+		}
 	}
-	v = class_lookup(inst->in_class, name, &class);
-	if (v == NULL)
-		goto error;
-	if (is_funcobject(v))
-		return newinstancemethodobject(v, (object *)inst,
-					       (object *)class);
- error:
-	err_setstr(AttributeError, name);
-	return NULL;
+	if (is_accessobject(v)) {
+		v = getaccessvalue(v, getclass());
+		if (v == NULL)
+			return NULL;
+	}
+	else
+		INCREF(v);
+	if (is_funcobject(v)) {
+		object *w = newinstancemethodobject(v, (object *)inst,
+						    (object *)class);
+		DECREF(v);
+		v = w;
+	}
+	return v;
 }
 
 static int
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index d7ba02e..102e577 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -105,10 +105,10 @@
 {
 	char buf[200];
 	if (m->m_self == NULL)
-		sprintf(buf, "<built-in function '%.80s'>", m->m_name);
+		sprintf(buf, "<built-in function %.80s>", m->m_name);
 	else
 		sprintf(buf,
-			"<built-in method '%.80s' of %.80s object at %lx>",
+			"<built-in method %.80s of %.80s object at %lx>",
 			m->m_name, m->m_self->ob_type->tp_name,
 			(long)m->m_self);
 	return newstringobject(buf);