Commit 57d4b13d authored by Evan Simpson's avatar Evan Simpson

Allow assertions in Scripts

parent 81e8827b
......@@ -83,7 +83,7 @@
#
##############################################################################
__version__='$Revision: 1.8 $'[11:-2]
__version__='$Revision: 1.9 $'[11:-2]
from zbytecodehacks.VSExec import SafeBlock, GuardedBinaryOps, \
UntupleFunction, RedirectWrites, WriteGuard, RedirectReads, ReadGuard, \
......@@ -108,9 +108,9 @@ for name in ('None', 'abs', 'chr', 'divmod', 'float', 'hash', 'hex', 'int',
for name in ('range', 'pow', 'DateTime', 'test', 'namespace', 'render'):
safebin[name] = getattr(safefuncs, name)
for name in ('ArithmeticError', 'AttributeError', 'EOFError',
'EnvironmentError', 'FloatingPointError', 'IOError',
'ImportError', 'IndexError', 'KeyError',
for name in ('ArithmeticError', 'AssertionError', 'AttributeError',
'EOFError', 'EnvironmentError', 'FloatingPointError',
'IOError', 'ImportError', 'IndexError', 'KeyError',
'LookupError', 'NameError', 'OSError', 'OverflowError',
'RuntimeError', 'StandardError', 'SyntaxError',
'TypeError', 'ValueError', 'ZeroDivisionError',
......
......@@ -89,7 +89,7 @@ This product provides support for Script objects containing restricted
Python code.
"""
__version__='$Revision: 1.14 $'[11:-2]
__version__='$Revision: 1.15 $'[11:-2]
import sys, os, traceback, re
from Globals import DTMLFile
......@@ -270,7 +270,8 @@ class PythonScript(Script, Historical, Cacheable):
join(self._v_errors, '\n') )
return self._newfun(allowSideEffect, {'$guard': theGuard,
'$write_guard': WriteGuard,
'$read_guard': ReadGuard},
'$read_guard': ReadGuard,
'__debug__': __debug__},
__builtins__=safebin)
def _editedBindings(self):
......
......@@ -343,7 +343,7 @@ def PublicNames(cb, w, fc):
'''
protected = []
for name in fc.co_names:
if name[:1]=='_' and len(name)>1:
if name[:1]=='_' and len(name)>1 and name != '__debug__':
protected.append(name)
if protected:
raise SyntaxError, ('Names starting with "_" are not allowed (%s).'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment