diff options
author | Jason Madden <jamadden@gmail.com> | 2017-04-26 07:43:41 -0500 |
---|---|---|
committer | Jason Madden <jamadden@gmail.com> | 2017-04-26 07:43:41 -0500 |
commit | 486a6c3801bcb7473f190adcc5f80f98fda87362 (patch) | |
tree | 19c69b09368928c1caec841caddaec9c58890492 | |
parent | 40e58ec495da58dd458a38912ef900a6b6e70a9e (diff) | |
download | zope-security-486a6c3801bcb7473f190adcc5f80f98fda87362.tar.gz |
Be specific that BTrees.keys and .values also are fixed in the same way that .items was. See #20 and #21.issue20-extension
-rw-r--r-- | CHANGES.rst | 2 | ||||
-rw-r--r-- | src/zope/security/checker.py | 3 | ||||
-rw-r--r-- | src/zope/security/tests/test_checker.py | 8 |
3 files changed, 10 insertions, 3 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index cb0e1d6..0203e6a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -18,7 +18,7 @@ Changes - Fix `issue 20 <https://github.com/zopefoundation/zope.security/issues/20>`_: iteration of pure-Python ``BTrees.items()``, and also creating a list from - ``BTrees.items()`` on Python 3. + ``BTrees.items()`` on Python 3. The same applies for ``keys()`` and ``values()``. 4.0.3 (2015-06-02) ------------------ diff --git a/src/zope/security/checker.py b/src/zope/security/checker.py index d75cfd5..3187afc 100644 --- a/src/zope/security/checker.py +++ b/src/zope/security/checker.py @@ -781,7 +781,8 @@ else: # to do iteration. Whitelist it so that they behave the same. # In addition, Python 3 will attempt to call __len__ on iterators # for a length hint, so the C implementations also need to be - # added to the _iteratorChecker. + # added to the _iteratorChecker. The same thing automatically + # applies for .keys() and .values() since they return the same type. # We do this here so that all users of zope.security can benefit # without knowing implementation details. # See https://github.com/zopefoundation/zope.security/issues/20 diff --git a/src/zope/security/tests/test_checker.py b/src/zope/security/tests/test_checker.py index d1bad49..ceda502 100644 --- a/src/zope/security/tests/test_checker.py +++ b/src/zope/security/tests/test_checker.py @@ -399,7 +399,9 @@ class CheckerTestsBase(object): from zope.security.checker import CheckerPublic import BTrees - checker = Checker({'items': CheckerPublic}) + checker = Checker({'items': CheckerPublic, + 'keys': CheckerPublic, + 'values': CheckerPublic}) for name in ('IF', 'II', 'IO', 'OI', 'OO'): for family_name in ('family32', 'family64'): @@ -408,10 +410,14 @@ class CheckerTestsBase(object): proxy = Proxy(btree, checker) # empty self.assertEqual([], list(proxy.items())) + self.assertEqual([], list(proxy.keys())) + self.assertEqual([], list(proxy.values())) # With an object btree[1] = 2 self.assertEqual([(1, 2)], list(proxy.items())) + self.assertEqual([1], list(proxy.keys())) + self.assertEqual([2], list(proxy.values())) class CheckerPyTests(unittest.TestCase, CheckerTestsBase): |