diff options
Diffstat (limited to 'src/zope/pagetemplate/engine.py')
-rw-r--r-- | src/zope/pagetemplate/engine.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/zope/pagetemplate/engine.py b/src/zope/pagetemplate/engine.py index df307e7..f3687d7 100644 --- a/src/zope/pagetemplate/engine.py +++ b/src/zope/pagetemplate/engine.py @@ -36,6 +36,16 @@ try: except ImportError: HAVE_UNTRUSTED = False +# PyPy doesn't support assigning to '__builtins__', even when +# using eval() (http://pypy.readthedocs.org/en/latest/cpython_differences.html), +# so don't try to use it. It won't work. +if HAVE_UNTRUSTED: + import platform + if platform.python_implementation() == 'PyPy': + HAVE_UNTRUSTED = False + del rcompile + del SafeBuiltins + from zope.tales.expressions import PathExpr, StringExpr, NotExpr, DeferExpr from zope.tales.expressions import SimpleModuleImporter from zope.tales.pythonexpr import PythonExpr @@ -320,9 +330,9 @@ class ZopeEngine(ZopeBaseEngine): wrapped in security proxies if the 'untrusted' extra is installed:: >>> r = context.evaluate('python: {12: object()}.values') - >>> str(type(r).__name__) == ( - ... '_Proxy' if HAVE_UNTRUSTED else - ... 'builtin_function_or_method') + >>> str(type(r).__name__) in ( + ... ('_Proxy',) if HAVE_UNTRUSTED else + ... ('builtin_function_or_method', 'method')) True >>> r = context.evaluate('python: {12: object()}[12].__class__') |