diff options
| author | Guido van Rossum <guido@python.org> | 1993-07-11 19:55:34 +0000 |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 1993-07-11 19:55:34 +0000 |
| commit | ed18fdc9fcd4a0c5d592ed4ee04a8337b60d8752 (patch) | |
| tree | 3909bcabf4d81f3ffb1f288f4f0619b1fa54f511 /Objects/object.c | |
| parent | 697e7abbc8f5d8188c09181e308827a45eacfc14 (diff) | |
| download | cpython-git-ed18fdc9fcd4a0c5d592ed4ee04a8337b60d8752.tar.gz | |
* 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.
Diffstat (limited to 'Objects/object.c')
| -rw-r--r-- | Objects/object.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index e28158e59b..a469797f58 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -194,6 +194,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; char *name; |
