Skip to content

Commit

Permalink
idea for fixing bug #142
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Oct 25, 2018
1 parent c055c52 commit a67e41d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/RestrictedPython/Guards.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,11 @@ def safer_getattr(object, name, getattr=getattr):
if isinstance(object, _compat.basestring) and name == 'format':
raise NotImplementedError(
'Using format() on a %s is not safe.' % object.__class__.__name__)
if name.startswith('_'):
raise ValueError(
'"{name}" is an invalid attribute name because it '
'starts with "_"'.format(name=name))
)
return getattr(object, name)


Expand Down

0 comments on commit a67e41d

Please sign in to comment.