mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
* accessobject.c (ownercheck): allow a base class access to protected
objects of its derived classes; allow anything that has an attribute named "__privileged__" access to anything. * object.[ch]: added hasattr() -- test whether getattr() will succeed.
This commit is contained in:
parent
697e7abbc8
commit
ed18fdc9fc
3 changed files with 42 additions and 15 deletions
|
|
@ -193,6 +193,20 @@ getattr(v, name)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
hasattr(v, name)
|
||||
object *v;
|
||||
char *name;
|
||||
{
|
||||
object *res = getattr(v, name);
|
||||
if (res != NULL) {
|
||||
DECREF(res);
|
||||
return 1;
|
||||
}
|
||||
err_clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
setattr(v, name, w)
|
||||
object *v;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue