[Zope-Checkins] CVS: Zope2 - Eval.py:1.1.2.3 RestrictionMutator.py:1.1.2.7
shane@digicool.com
shane@digicool.com
Tue, 24 Apr 2001 22:51:32 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/RestrictedPython
In directory korak:/tmp/cvs-serv24939
Modified Files:
Tag: RestrictedPythonBranch
Eval.py RestrictionMutator.py
Log Message:
Fixed code and tests so tests pass again. (Please run tests. :-) )
--- Updated File Eval.py in package Zope2 --
--- Eval.py 2001/04/25 00:56:31 1.1.2.2
+++ Eval.py 2001/04/25 02:51:31 1.1.2.3
@@ -124,6 +124,8 @@
self.expr = expr
self.globals = globals
self.code, err, warn, used = compile_restricted_eval(expr, '<string>')
+ if err:
+ raise SyntaxError, err[0]
self.used = tuple(used.keys())
def eval(self, mapping):
--- Updated File RestrictionMutator.py in package Zope2 --
--- RestrictionMutator.py 2001/04/25 00:56:31 1.1.2.6
+++ RestrictionMutator.py 2001/04/25 02:51:31 1.1.2.7
@@ -270,9 +270,10 @@
gen.emit('RETURN_VALUE')
return gen.getCode(), None, rm.warnings, rm.used_names
-DEBUG = 1
+DEBUG = 0
def compile_restricted(source, filename, mode):
- '''Returns restricted compiled code.'''
+ '''Returns restricted compiled code. The signature of this
+ function should match the signature of the builtin compile.'''
if DEBUG:
from time import clock
start = clock()
@@ -287,8 +288,11 @@
if DEBUG:
end = clock()
print 'compile_restricted: %d ms for %s' % (
- (end - start) * 1000, repr(s))
- return r
+ (end - start) * 1000, repr(filename))
+ code, errors, warnings, used_names = r
+ if errors:
+ raise SyntaxError, errors[0]
+ return code
class Noisy:
'''Test guard class that babbles about accesses'''