summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2015-06-02 17:05:27 -0400
committerTres Seaver <tseaver@palladion.com>2015-06-02 17:05:27 -0400
commit15bcfca4ae23e94586af3df86f607f9047c8e188 (patch)
tree7660eff1a7e38dfa4708ea6d2917ed49a47bf61f
parentee409d022cba7fed2ed8e2c35f92dfe56901a625 (diff)
parentb99d64ba9e90f2f3bf69b68613b4a7e48a1c2345 (diff)
downloadzope-security-15bcfca4ae23e94586af3df86f607f9047c8e188.tar.gz
Merge branch 'NextThought-pypy-support'
-rw-r--r--CHANGES.rst204
-rw-r--r--src/zope/security/checker.py5
-rw-r--r--src/zope/security/tests/test_checker.py17
3 files changed, 118 insertions, 108 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index f420f45..4d6c13a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,25 +4,26 @@ Changes
4.0.3 (unreleased)
------------------
-- TBD
+- Fix iteration over security proxies in Python 3 using the pure-Python
+ implementation.
4.0.2 (2015-06-02)
------------------
-- Fixed compatibility with ``zope.proxy`` 4.1.5 under PyPy.
+- Fix compatibility with ``zope.proxy`` 4.1.5 under PyPy.
-- Fixed the very first call to ``removeSecurityProxy`` returning
+- Fix the very first call to ``removeSecurityProxy`` returning
incorrect results if given a proxy under PyPy.
4.0.1 (2014-03-19)
------------------
-- Added support for Python 3.4.
+- Add support for Python 3.4.
4.0.0 (2013-07-09)
------------------
-- Updated ``boostrap.py`` to version 2.2.
+- Update ``boostrap.py`` to version 2.2.
- Bugfix: ZOPE_WATCH_CHECKERS=2 used to incorrectly suppress
unauthorized/forbidden warnings.
@@ -33,9 +34,9 @@ Changes
4.0.0b1 (2013-03-11)
--------------------
-- Added support for PyPy.
+- Add support for PyPy.
-- Fixed extension compilation on windows python 3.x
+- Fix extension compilation on windows python 3.x
4.0.0a5 (2013-02-28)
@@ -60,7 +61,7 @@ Changes
4.0.0a2 (2013-02-15)
--------------------
-- Added back the ``untrustedpython`` extra: now pulls in
+- Add back the ``untrustedpython`` extra: now pulls in
``zope.untrustedpython``. Restored deprecated backward-compatible imports
for ``zope.security.untrustedpython.{builtins,interpreter,rcompile}``
(the extra and the imports are to be removed in version 4.1).
@@ -69,52 +70,52 @@ Changes
4.0.0a1 (2013-02-14)
--------------------
-- Added support for Python 3.2 and 3.3.
+- Add support for Python 3.2 and 3.3.
-- 100% unit test coverage.
+- Bring unit test coverage to 100%.
- ``zope.security.untrustedpython`` moved to separate project:
``zope.untrustedpython``
-- Converted use of ``assert`` in non-test code to apprpriate error types:
+- Convert use of ``assert`` in non-test code to apprpriate error types:
- Non-dict's passed to ``Checker.__init__``.
-- Removed dprecattion of ``zope.security.adapter.TrustedAdapterFactory``.
+- Remove dprecattion of ``zope.security.adapter.TrustedAdapterFactory``.
Although it has been marked as deprectaed since before Zope3 3.2, current
versions of ``zope.compoent`` still rely on it.
-- Converted doctests to Sphinx documentation in 'docs'.
+- Convert doctests to Sphinx documentation in 'docs'.
-- Added 'setup.py docs' alias (installs ``Sphinx`` and dependencies).
+- Add ``setup.py docs`` alias (installs ``Sphinx`` and dependencies).
-- Added 'setup.py dev' alias (runs ``setup.py develop`` plus installs
+- Add ``setup.py dev`` alias (runs ``setup.py develop`` plus installs
``nose`` and ``coverage``).
-- Made non-doctest tests fully independent of ``zope.testing``.
+- Make non-doctest tests fully independent of ``zope.testing``.
Two modules, ``zope.security.checker`` and ``zope.security.management``,
register cleanups with ``zope.testing`` IFF it is importable, but the
tests no longer rely on it.
-- Enabled building extensions without the 'svn:external' of the ``zope.proxy``
- headers into our 'include' dir.
+- Enable building extensions without the ``svn:external`` of the ``zope.proxy``
+ headers into our ``include`` dir.
-- Bumped ``zope.proxy`` dependency to ">= 4.1.0" to enable compilation
+- Bump ``zope.proxy`` dependency to ">= 4.1.0" to enable compilation
on Py3k.
-- Replaced deprecated ``zope.component.adapts`` usage with equivalent
+- Replace deprecated ``zope.component.adapts`` usage with equivalent
``zope.component.adapter`` decorator.
-- Replaced deprecated ``zope.interface.classProvides`` usage with equivalent
+- Replace deprecated ``zope.interface.classProvides`` usage with equivalent
``zope.interface.provider`` decorator.
-- Replaced deprecated ``zope.interface.implements`` usage with equivalent
+- Replace deprecated ``zope.interface.implements`` usage with equivalent
``zope.interface.implementer`` decorator.
-- Dropped support for Python 2.4 and 2.5.
+- Drop support for Python 2.4 and 2.5.
-- Added test convenience helper ``create_interaction`` and
+- Add test convenience helper ``create_interaction`` and
``with interaction()``.
3.9.0 (2012-12-21)
@@ -139,7 +140,7 @@ Changes
3.8.3 (2011-09-24)
------------------
-- Fixed a regression introduced in 3.8.1: ``zope.location``\'s LocationProxy
+- Fix a regression introduced in 3.8.1: ``zope.location``\'s LocationProxy
did not get a security checker if ``zope.security.decorator`` was not
imported manually. Now ``zope.security.decorator`` is imported in
``zope.security.proxy`` without re-introducing the circular import fixed in
@@ -154,7 +155,7 @@ Changes
3.8.1 (2011-05-03)
------------------
-- Fixed circular import beween ``zope.security.decorator`` and
+- Fix circular import beween ``zope.security.decorator`` and
``zope.security.proxy`` which led to an ``ImportError`` when only
importing ``zope.security.decorator``.
@@ -162,9 +163,9 @@ Changes
3.8.0 (2010-12-14)
------------------
-- Added tests for our own ``configure.zcml``.
+- Add tests for our own ``configure.zcml``.
-- Added ``zcml`` extra dependencies, run related tests only if
+- Add ``zcml`` extra dependencies; run related tests only if
``zope.configuration`` is available.
- Run tests related to the ``untrustedpython`` functionality only if
@@ -174,13 +175,14 @@ Changes
3.7.3 (2010-04-30)
------------------
-- Prefer the standard libraries doctest module to the one from zope.testing.
+- Prefer the standard library's ``doctest`` module to the one from
+ ``zope.testing``.
-- Fixed directlyProvides IVocabularyFactory for PermissionIdsVocabulary in
- Python code, even if it's unnecessary because IVocabularyFactory is provided
- in zcml.
+- Ensure ``PermissionIdsVocabulary`` directly provides ``IVocabularyFactory``,
+ even though it might be unnecessary because ``IVocabularyFactory`` is
+ provided in ZCML.
-- Removed the dependency on the zope.exceptions package: zope.security.checker
+- Remove the dependency on the zope.exceptions package: zope.security.checker
now imports ``DuplicationError`` from zope.exceptions if available, otherwise
it defines a package-specific ``DuplicationError`` class which inherits from
Exception.
@@ -189,7 +191,7 @@ Changes
3.7.2 (2009-11-10)
------------------
-- Added compatibility with Python 2.6 abstract base classes.
+- Add compatibility with Python 2.6 abstract base classes.
3.7.1 (2009-08-13)
@@ -207,7 +209,7 @@ Changes
3.7.0 (2009-05-13)
------------------
-- Made ``pytz`` a soft dependency: the checker for ``pytz.UTC`` is
+- Make ``pytz`` a soft dependency: the checker for ``pytz.UTC`` is
created / tested only if the package is already present. Run
``bin/test_pytz`` to run the tests with ``pytz`` on the path.
@@ -215,12 +217,12 @@ Changes
3.6.3 (2009-03-23)
------------------
-- Ensure that simple zope.schema's VocabularyRegistry is used for
- PermissionVocabulary tests, because it's replaced implicitly in
- environments with zope.app.schema installed that makes that tests
+- Ensure that simple zope.schema's ``VocabularyRegistry`` is used for
+ ``PermissionVocabulary`` tests, because it's replaced implicitly in
+ environments with ``zope.app.schema`` installed that makes that tests
fail.
-- Fixed a bug in DecoratedSecurityCheckerDescriptor which made
+- Fix a bug in ``DecoratedSecurityCheckerDescriptor`` which made
security-wrapping location proxied exception instances throw
exceptions on Python 2.5.
See https://bugs.launchpad.net/zope3/+bug/251848
@@ -229,24 +231,24 @@ Changes
3.6.2 (2009-03-14)
------------------
-- Add zope.i18nmessageid.Message to non-proxied basic types. It's okay, because
- messages are immutable. It was done by zope.app.security before.
+- Add ``zope.i18nmessageid.Message`` to non-proxied basic types. It's okay,
+ because messages are immutable. Done previously by ``zope.app.security``.
-- Add "__name__" and "__parent__" attributes to list of available by default.
- This was also done by zope.app.security package before.
+- Add ``__name__`` and ``__parent__`` attributes to list of available by
+ default. Done previously by ``zope.app.security``.
-- Added PermissionsVocabulary and PermissionIdsVocabulary vocabularies
- to the ``zope.security.permission`` module. They were moved from
- the ``zope.app.security`` package.
+- Move ``PermissionsVocabulary`` and ``PermissionIdsVocabulary`` vocabularies
+ to the ``zope.security.permission`` module from the ``zope.app.security``
+ package.
- Add zcml permission definitions for most common and useful permissions,
- like "zope.View" and "zope.ManageContent", as well as for the special
- "zope.Public" permission. They are placed in a separate "permissions.zcml"
- file, so it can be easily excluded/redefined. They are selected part of
- permissions moved from ``zope.app.security`` and used by many zope.*
- packages.
+ like ``zope.View`` and ``zope.ManageContent``, as well as for the special
+ ``zope.Public`` permission. They are placed in a separate
+ ``permissions.zcml`` file, so it can be easily excluded/redefined. They are
+ selected part of permissions moved from ``zope.app.security`` and used by
+ many ``zope.*`` packages.
-- Add `addCheckerPublic` helper function in ``zope.security.testing`` module
+- Add ``addCheckerPublic`` helper function in ``zope.security.testing`` module
that registers the "zope.Public" permission as an IPermission utility.
- Add security declarations for the ``zope.security.permisson.Permission``
@@ -261,12 +263,12 @@ Changes
- Use ``from`` imports instead of ``zope.deferred`` to avoid circular
import problems, thus drop dependency on ``zope.deferredimport``.
-- Raise NoInteraction when zope.security.checkPermission is called
+- Raise ``NoInteraction`` when ``zope.security.checkPermission`` is called
without interaction being active (LP #301565).
- Don't define security checkers for deprecated set types from the
"sets" module on Python 2.6. It's discouraged to use them and
- `set` and `frozenset` built-in types should be used instead.
+ ``set`` and ``frozenset`` built-in types should be used instead.
- Change package's mailng list address to zope-dev at zope.org as
zope3-dev at zope.org is now retired.
@@ -277,32 +279,32 @@ Changes
3.6.0 (2009-01-31)
------------------
-- Install decorated security checker support on LocationProxy from the
+- Install decorated security checker support on ``LocationProxy`` from the
outside.
-- Added support to bootstrap on Jython.
+- Add support to bootstrap on Jython.
-- Moved the `protectclass` module from `zope.app.security` to this
- package to reduce the number of dependencies on `zope.app.security`.
+- Move the ``protectclass`` module from ``zope.app.security`` to this
+ package to reduce the number of dependencies on ``zope.app.security``.
-- Moved the <module> directive implementation from `zope.app.security`
+- Move the ``<module>`` directive implementation from ``zope.app.security``
to this package.
-- Moved the <class> directive implementation from `zope.app.component`
+- Move the ``<class>`` directive implementation from ``zope.app.component``
to this package.
3.5.2 (2008-07-27)
------------------
-- Made C code compatible with Python 2.5 on 64bit architectures.
+- Make C code compatible with Python 2.5 on 64bit architectures.
3.5.1 (2008-06-04)
------------------
-- Add `frozenset`, `set`, `reversed`, and `sorted` to the list of safe
- builtins.
+- Add ``frozenset``, ``set``, ``reversed``, and ``sorted`` to the list of
+ safe builtins.
3.5.0 (2008-03-05)
@@ -315,23 +317,23 @@ Changes
3.4.3 - (2009/11/26)
--------------------
-- Backported a fix made by Gary Poster to the 3.4 branch:
+- Backport a fix made by Gary Poster to the 3.4 branch:
Fix for LP bug 181833 (from Gustavo Niemeyer). Before "visiting" a
sub-object, a check should be made to ensure the object is still valid.
Because garbage collection may involve loops, if you garbage collect an
object, it is possible that the actions done on this object may modify the
state of other objects. This may cause another round of garbage collection,
- eventually generating a segfault (see LP bug). The Py_VISIT macro does the
- necessary checks, so it is used instead of the previous code.
+ eventually generating a segfault (see LP bug). The ``Py_VISIT`` macro does
+ the necessary checks, so it is used instead of the previous code.
3.4.2 - (2009/03/23)
--------------------
-- Added dependency 'zope.thread' to setup.py, without the tests were
+- Add dependency on ``zope.thread`` to setup.py; without it, the tests were
failing.
-- Backported a fix made by Albertas Agejevas to the 3.4 branch. He
+- Backport a fix made by Albertas Agejevas to the 3.4 branch. He
fixed a bug in DecoratedSecurityCheckerDescriptor which made
security-wrapping location proxied exception instances throw
exceptions on Python 2.5. See
@@ -341,36 +343,36 @@ Changes
3.4.1 - 2008/07/27
------------------
-- Made C code compatible with Python 2.5 on 64bit architectures.
+- Make C code compatible with Python 2.5 on 64bit architectures.
3.4.0 (2007-10-02)
------------------
-- Updated meta-data.
+- Update meta-data.
3.4.0b5 (2007-08-15)
--------------------
-- Bug: Fixed a circular import in the C implementation.
+- Fix a circular import in the C implementation.
3.4.0b4 (2007-08-14)
--------------------
-- Bug: ``zope.security.management.system_user`` had an ugly/brittle id.
+- Improve ugly/brittle ID of ``zope.security.management.system_user``.
3.4.0b3 (2007-08-14)
--------------------
-- ``zope.security`` now works on Python 2.5
+- Add support for Python 2.5.
- Bug: ``zope.security.management.system_user`` wasn't a valid principal
(didn't provide IPrincipal).
-- Bug: Fixed inclusion of doctest to use the doctest module from
+- Bug: Fix inclusion of doctest to use the doctest module from
``zope.testing``. Now tests can be run multiple times without
breaking. (#98250)
@@ -378,9 +380,9 @@ Changes
3.4.0b2 (2007-06-15)
--------------------
-- Bug: Removed stack extraction in newInteraction. When using eggs this is an
- extremly expensive function. The publisher is now more than 10 times faster
- when using eggs and about twice as fast with a zope trunk checkout.
+- Bug: Remove stack extraction in ``newInteraction``. When using eggs this is
+ an extremly expensive function. The publisher is now more than 10 times
+ faster when using eggs and about twice as fast with a zope trunk checkout.
3.4.0b1
@@ -396,18 +398,18 @@ individual package and have been documented in the Zope 3 changelog.
3.2.0 (2006-01-05)
------------------
-- Corresponds to the verison of the zope.security package shipped as part of
- the Zope 3.2.0 release.
+- Corresponds to the verison of the ``zope.security`` package shipped as part
+ of the Zope 3.2.0 release.
-- Removed deprecated helper functions, 'proxy.trustedRemoveSecurityProxy' and
- 'proxy.getProxiedObject'.
+- Remove deprecated helper functions, ``proxy.trustedRemoveSecurityProxy``
+ and ``proxy.getProxiedObject``.
-- Made handling of 'management.{end,restore}Interaction' more careful w.r.t.
+- Make handling of ``management.{end,restore}Interaction`` more careful w.r.t.
edge cases.
-- Made behavior of 'canWrite' consistent with 'canAccess': if 'canAccess'
- does not raise 'ForbiddenAttribute', then neither will 'canWrite'. See:
- http://www.zope.org/Collectors/Zope3-dev/506
+- Make behavior of ``canWrite`` consistent with ``canAccess``:
+ if ``canAccess`` does not raise ``ForbiddenAttribute``, then neither will
+ ``canWrite``. See: http://www.zope.org/Collectors/Zope3-dev/506
- Code style / documentation / test fixes.
@@ -415,28 +417,28 @@ individual package and have been documented in the Zope 3 changelog.
3.1.0 (2005-10-03)
------------------
-- Added support for use of the new Python 2.4 datatypes, 'set' and
- 'frozenset', within checked code.
+- Add support for use of the new Python 2.4 datatypes, ``set`` and
+ ``frozenset``, within checked code.
-- C security proxy acquired a dependency on the 'proxy.h' header from the
- 'zope.proxy' package.
+- Make the C security proxy depend on the ``proxy.h`` header from the
+ ``zope.proxy`` package.
-- XXX: the spelling of the '#include' is bizarre! It seems to be related to
- 'zpkg'-based builds, and should likely be revisited. For the moment, I have
- linked in the 'zope.proxy' package into our own 'include' directory. See
+- XXX: the spelling of the ``#include`` is bizarre! It seems to be related to
+ ``zpkg``-based builds, and should likely be revisited. For the moment, I have
+ linked in the ``zope.proxy`` package into our own ``include`` directory. See
the subversion checkin: http://svn.zope.org/Zope3/?rev=37882&view=rev
-- Updated checker to avoid re-proxying objects which have and explicit
- '__Security_checker__' assigned.
+- Update checker to avoid re-proxying objects which have and explicit
+ ``__Security_checker__`` assigned.
-- Corresponds to the verison of the zope.security package shipped as part of
+- Corresponds to the verison of the ``zope.security`` package shipped as part of
the Zope 3.1.0 release.
-- Clarified contract of 'IChecker' to indicate that its 'check*' methods may
- raise only 'Forbidden' or 'Unauthorized' exceptions.
+- Clarify contract of ``IChecker`` to indicate that its ``check*`` methods may
+ raise only ``Forbidden`` or ``Unauthorized`` exceptions.
-- Added interfaces, ('IPrincipal', 'IGroupAwarePrincipal', 'IGroup', and
- 'IPermission') specifying contracts of components in the security framework.
+- Add interfaces, (``IPrincipal``, ``IGroupAwarePrincipal``, ``IGroup``, and
+ ``IPermission``) specifying contracts of components in the security framework.
- Code style / documentation / test fixes.
@@ -444,5 +446,5 @@ individual package and have been documented in the Zope 3 changelog.
3.0.0 (2004-11-07)
------------------
-- Corresponds to the version of the zope.security package shipped as part of
- the Zope X3.0.0 release.
+- Corresponds to the version of the ``zope.security`` package shipped as part
+ of the Zope X3.0.0 release.
diff --git a/src/zope/security/checker.py b/src/zope/security/checker.py
index 8fc4890..d5f261c 100644
--- a/src/zope/security/checker.py
+++ b/src/zope/security/checker.py
@@ -604,7 +604,7 @@ _typeChecker = NamesChecker(
'__implemented__'])
_namedChecker = NamesChecker(['__name__'])
-_iteratorChecker = NamesChecker(['next', '__iter__', '__len__'])
+_iteratorChecker = NamesChecker(['next', '__next__', '__iter__', '__len__'])
_setChecker = NamesChecker(['__iter__', '__len__', '__str__', '__contains__',
'copy', 'difference', 'intersection', 'issubset',
@@ -651,7 +651,7 @@ _basic_types = {
datetime.time: NoProxy,
datetime.tzinfo: NoProxy,
}
-if PYTHON2:
+if PYTHON2:
_basic_types[long] = NoProxy
_basic_types[unicode] = NoProxy
else: #pragma NO COVER
@@ -783,4 +783,3 @@ except ImportError: #pragma NO COVER
pass
else:
addCleanUp(_clear)
-
diff --git a/src/zope/security/tests/test_checker.py b/src/zope/security/tests/test_checker.py
index 0eabfb6..c5c01e7 100644
--- a/src/zope/security/tests/test_checker.py
+++ b/src/zope/security/tests/test_checker.py
@@ -620,7 +620,7 @@ class Test_MultiChecker(unittest.TestCase):
class IFoo(Interface):
bar = Attribute('Bar')
other_perm = object()
- checker = self._callFUT([(IFoo, other_perm),
+ checker = self._callFUT([(IFoo, other_perm),
(('foo', 'baz'), CheckerPublic)])
self.assertTrue(checker.permission_id('foo') is CheckerPublic)
self.assertTrue(checker.permission_id('bar') is other_perm)
@@ -636,7 +636,7 @@ class Test_MultiChecker(unittest.TestCase):
bar = Attribute('Bar')
other_perm = object()
self.assertRaises(DuplicationError,
- self._callFUT, [(IFoo, other_perm),
+ self._callFUT, [(IFoo, other_perm),
(('foo', 'bar'), CheckerPublic)])
def test_w_spec_as_mapping(self):
@@ -784,7 +784,7 @@ class Test_getCheckerForInstancesOf(unittest.TestCase):
from zope.security.checker import _checkers
class Foo(object):
pass
- checker = _checkers[Foo] = object()
+ checker = _checkers[Foo] = object()
self.assertTrue(self._callFUT(Foo) is checker)
@@ -1362,7 +1362,7 @@ class BasicTypesTests(unittest.TestCase):
BasicTypes.update({Foo: checker})
self.assertTrue(BasicTypes[Foo] is checker)
self.assertTrue(_checkers[Foo] is checker)
-
+
# Pre-geddon tests start here
@@ -1601,6 +1601,15 @@ class Test(unittest.TestCase):
# proxy2 = checker.proxy(proxy)
# self.assertTrue(proxy2 is proxy, [proxy, proxy2])
+ def test_iteration(self):
+ from zope.security.checker import ProxyFactory
+ from zope.security.checker import selectChecker
+
+ for i in ((1,), [1]):
+ _iter = iter(i)
+ proxy = ProxyFactory(_iter, selectChecker(_iter))
+ self.assertEqual(next(proxy), 1)
+
def testLayeredProxies(self):
#Test that a Proxy will not be re-proxied.
from zope.security.proxy import Proxy, getObject