Skip to content

Commit

Permalink
Allow assertions in Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan Simpson committed Jan 15, 2001
1 parent 1f1f420 commit f2fdf1c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Guarded.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand All @@ -108,9 +108,9 @@ def secureModule(*args):
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',
Expand Down
5 changes: 3 additions & 2 deletions PythonScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
Python code.
"""

__version__='$Revision: 1.14 $'[11:-2]
__version__='$Revision: 1.15 $'[11:-2]

import sys, os, traceback, re
from Globals import DTMLFile
Expand Down Expand Up @@ -270,7 +270,8 @@ def _makeFunction(self, allowSideEffect=0):
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):
Expand Down
2 changes: 1 addition & 1 deletion zbytecodehacks/VSExec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).'
Expand Down

0 comments on commit f2fdf1c

Please sign in to comment.