[Zope-Checkins] CVS: Zope/lib/python/RestrictedPython -
Guards.py:1.11
Fred Drake
cvs-admin at zope.org
Thu Nov 6 10:47:46 EST 2003
Update of /cvs-repository/Zope/lib/python/RestrictedPython
In directory cvs.zope.org:/tmp/cvs-serv1812
Modified Files:
Guards.py
Log Message:
get the exceptions and warnings Python gives us instead of hard-coding
the list of names
=== Zope/lib/python/RestrictedPython/Guards.py 1.10 => 1.11 ===
--- Zope/lib/python/RestrictedPython/Guards.py:1.10 Wed Nov 5 20:11:54 2003
+++ Zope/lib/python/RestrictedPython/Guards.py Thu Nov 6 10:47:45 2003
@@ -14,6 +14,7 @@
__version__='$Revision$'[11:-2]
+import exceptions
import new
safe_builtins = {}
@@ -21,15 +22,12 @@
'len', 'max', 'min', 'oct', 'ord', 'round', 'str', 'pow',
'apply', 'callable', 'cmp', 'complex', 'isinstance',
'issubclass', 'long', 'repr', 'range', 'list', 'tuple',
- 'unichr', 'unicode',
- 'Exception', 'True', 'False', 'bool',
- 'ArithmeticError', 'AssertionError', 'AttributeError',
- 'EOFError', 'EnvironmentError', 'FloatingPointError',
- 'IOError', 'ImportError', 'IndexError', 'KeyError',
- 'LookupError', 'NameError', 'OSError', 'OverflowError',
- 'RuntimeError', 'StandardError', 'SyntaxError',
- 'TypeError', 'UnicodeError', 'ValueError', 'ZeroDivisionError',):
+ 'unichr', 'unicode', 'True', 'False', 'bool',):
safe_builtins[name] = __builtins__[name]
+
+for name in dir(exceptions):
+ if name[0] != "_":
+ safe_builtins[name] = getattr(exceptions, name)
def _full_read_guard(g_attr, g_item):
More information about the Zope-Checkins
mailing list