-
Notifications
You must be signed in to change notification settings - Fork 15
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pure-Python BTree.items() can't be iterated, C implementation allows it #20
Comments
Some observations:
So, all of that leads me to this conclusion:
This could be done in a few different ways:
I've tested that the Thoughts? |
Another wrinkle is that Python 3.x will attempt to call I'm working on a PR. This package seems like the most logical place to address the issue. |
Also fix ``list(proxy_btree.items())`` (or a list comprehension of the same) in Python 3, which wants the ``__len__`` for a hint. This is a central place to make sure these all behave consistently. Fixes #20
Also fix ``list(proxy_btree.items())`` (or a list comprehension of the same) in Python 3, which wants the ``__len__`` for a hint. This is a central place to make sure these all behave consistently. Fixes #20 Also drop pypy3 As a 3.2 implementation, it's not supported by pip anymore. There is a much more recent version, 3.5-beta, but it's not on Travis yet. The 3.3-alpha which is on Travis is a dead end.
Also fix ``list(proxy_btree.items())`` (or a list comprehension of the same) in Python 3, which wants the ``__len__`` for a hint. This is a central place to make sure these all behave consistently. Fixes #20 Also drop pypy3 As a 3.2 implementation, it's not supported by pip anymore. There is a much more recent version, 3.5-beta, but it's not on Travis yet. The 3.3-alpha which is on Travis is a dead end.
…sion 4.1.0 4.1.0 (2017-04-24) ------------------ - When testing ``PURE_PYTHON`` environments under ``tox``, avoid poisoning the user's global wheel cache. - Drop support for Python 2.6 and 3.2. - Add support for Python 3.5 and 3.6. - 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.
Fixes #23. Also a further fix for #20 (you couldn't iterate a BTree all by itself). Refactor the test case for BTree to be a shared implementation and confirm that it works as expected for dict, using the actual dict checker. Then apply it to OrderedDict and BTree and fix the resulting failures by refactoring the fixup in checker.py to a shared implementation and applying it.
(As reported in zopefoundation/zope.proxy#16.)
Given this code:
It passes using the C implementation of everything (specifically, the C implementation of BTrees), but it fails using pure-python (Python implementation of BTrees):
(Note that using
CheckerPy
also works with the C implementation of BTrees and fails with the Python version. Also note this happens for both empty trees and for trees that have objects in them. In the empty case,items()
returns a tuple and the exception isForbiddenAttribute: ('__iter__', ())
)The checker logic doesn't raise an exception if the object doesn't have the
__iter__
attribute:The C implementation of
TreeItems
does not have an__iter__
method:Instead, the
TreeItems
implements bothtp_iter
andtp_iternext
and is its owniter
(tp_iter
just returnsself
). But the objects returned by the Python implementation all (necessarily) have an__iter__
.Thoughts on how to resolve this? Maybe this isn't a
zope.security
bug, per-se, but whatever sets up the permissions for zope.app should specifically allowiter
onBTrees._base._TreeItems
? (That smells bad to me, not least because it fails for the empty/tuple case.)The text was updated successfully, but these errors were encountered: