mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
* 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!)
This commit is contained in:
parent
81daa32c15
commit
b3f7258f14
7 changed files with 112 additions and 49 deletions
|
@ -99,6 +99,15 @@ setaccessowner(op, class)
|
|||
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 @@ access_repr(ap)
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue