Skip to content

Commit

Permalink
Add hasattr that returns false if you aren't allowed to access the name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Simpson committed Dec 21, 2000
1 parent 205caf9 commit e45c0c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Guarded.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#
##############################################################################

__version__='$Revision: 1.4 $'[11:-2]
__version__='$Revision: 1.5 $'[11:-2]

from zbytecodehacks.VSExec import SafeBlock, GuardedBinaryOps, \
UntupleFunction, RedirectWrites, WriteGuard, RedirectReads, ReadGuard, \
Expand Down Expand Up @@ -160,6 +160,14 @@ def __careful_delattr__(object, name):
delattr(WriteGuard(object), name)
safebin['delattr'] = __careful_delattr__

def __careful_hasattr__(object, name):
try:
__careful_getattr__(object, name)
except (AttributeError, ValidationError):
return 0
return 1
safebin['hasattr'] = __careful_hasattr__

def __careful_filter__(f, seq, skip_unauthorized=0):
if type(seq) is type(''):
return filter(f, seq)
Expand Down

0 comments on commit e45c0c7

Please sign in to comment.