summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2015-06-02 13:16:47 -0400
committerTres Seaver <tseaver@palladion.com>2015-06-02 13:16:47 -0400
commit083c2d54773fb7c32156aff15771fc4e0247ca9d (patch)
tree611328bfccc921f2ec5979e0ca15c0e028498ea1
parent762a931cf5cca67d514c2e926a3196d62184d092 (diff)
parent591c1334d864c223c43d29cfd02deb643ba53b29 (diff)
downloadzope-pagetemplate-083c2d54773fb7c32156aff15771fc4e0247ca9d.tar.gz
Merge pull request #4 from NextThought/pypy-support
Add PyPy support.
-rw-r--r--.travis.yml5
-rw-r--r--CHANGES.rst1
-rw-r--r--setup.py6
-rw-r--r--src/zope/pagetemplate/engine.py16
-rw-r--r--src/zope/pagetemplate/tests/test_engine.py3
-rw-r--r--tox.ini4
6 files changed, 22 insertions, 13 deletions
diff --git a/.travis.yml b/.travis.yml
index f1e555c..796195e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,9 +5,8 @@ env:
- TOXENV=py27
- TOXENV=py33
- TOXENV=py34
-# PyPy support needs cleanup of doctests, plus some help from zope.security.
-# - TOXENV=pypy
-# - TOXENV=pypy3
+ - TOXENV=pypy
+ - TOXENV=pypy3
install:
- travis_retry pip install tox
script:
diff --git a/CHANGES.rst b/CHANGES.rst
index 688befe..14c0900 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,6 +7,7 @@ Changes
- Allow short-circuit traversal for non-proxied dict subclasses. See:
https://github.com/zopefoundation/zope.pagetemplate/pull/3 .
+- Add support for PyPy.
4.1.0 (2014-12-27)
------------------
diff --git a/setup.py b/setup.py
index bc66a17..8012e37 100644
--- a/setup.py
+++ b/setup.py
@@ -70,7 +70,7 @@ TESTS_REQUIRE = [
setup(name='zope.pagetemplate',
- version='4.1.1.dev0',
+ version='4.1.2.dev0',
author='Zope Foundation and Contributors',
author_email='zope-dev@zope.org',
description='Zope Page Templates',
@@ -99,9 +99,7 @@ setup(name='zope.pagetemplate',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: CPython',
-# PyPy support needs cleanup of doctests, plus some help from
-# zope.security.
-# 'Programming Language :: Python :: Implementation :: PyPy',
+ 'Programming Language :: Python :: Implementation :: PyPy',
'Natural Language :: English',
'Operating System :: OS Independent',
'Topic :: Internet :: WWW/HTTP',
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__')
diff --git a/src/zope/pagetemplate/tests/test_engine.py b/src/zope/pagetemplate/tests/test_engine.py
index 097a597..ab3b5ca 100644
--- a/src/zope/pagetemplate/tests/test_engine.py
+++ b/src/zope/pagetemplate/tests/test_engine.py
@@ -94,6 +94,9 @@ def test_suite():
(re.compile(r"<class 'zope.security._proxy._Proxy'>"),
"<type 'zope.security._proxy._Proxy'>"),
(re.compile(r"<class 'list'>"), "<type 'list'>"),
+ # PyPy/pure-Python implementation
+ (re.compile(r"<class 'zope.security.proxy.ProxyPy'>"),
+ "<type 'zope.security._proxy._Proxy'>"),
])
suite = unittest.TestSuite()
diff --git a/tox.ini b/tox.ini
index b449252..9b500be 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,8 +1,6 @@
[tox]
envlist =
-# PyPy support needs cleanup of doctests, plus some help from zope.security.
-# py26,py27,py33,py34,pypy,pypy3
- py26,py27,py33,py34
+ py26,py27,py33,py34,pypy,pypy3
[testenv]
deps =