-
Notifications
You must be signed in to change notification settings - Fork 17
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
Make dict views behave like their unrestricted versions #147
Make dict views behave like their unrestricted versions #147
Conversation
c5d4a05
to
e866525
Compare
e866525
to
cd7e568
Compare
What was most problematic for me when porting a python2 code base was constructs like: d = {}
...
if len(d.keys()):
... which was causing an error "SafeIter has no len" and d = {}
...
if d.keys():
... which was silently true when d is empty. Most of the actual implementation is delegated to |
cd7e568
to
3666a7a
Compare
There was something wrong with the first version of the patch, it is now ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, but then again I do not have any deep knowledge about the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though I now know how to access branches in foreign repositories (thanks to @navytux), I would prefer if you would make your future PRs directly in the target repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, you consider adding my comment suggestion.
I think appveyor breaks because this PR is created from a fork of the repository instead of a branch. Could you please recreate it on a branch inside the zopefoundation repository to see that also the windows version runs successfully. (As a rule of thumb: Creating branches in the main repostory (instead of forks) is running smoother and is liked more by the zopefoundation maintainers.) |
unlike the restricted versions, the unrestricted versions: - are not iterators, they are views - have a len - are false when the mapping is empty, true otherwise - are instances of collections.abc.MappingView This change aligns the behavior of restricted versions with the behavior of unrestricted one, while keeping the "guard", which validates the access with the security manager. During this refactoring, also change `.items()` to validate ach keys and values, like `.keys()` and `.values()` do. Co-authored-by: Dieter Maurer <d-maurer@users.noreply.github.com>
6ac5c18
to
6722f7e
Compare
After some time the appveyor build was OK, so I merged, thank you everybody ! |
actually, it was probably not "after some time", but after I pushed the same commit in zopefoundation/AccessControl |
unlike the restricted versions, the unrestricted versions:
This change aligns the behavior of restricted versions with the behavior of unrestricted one, while keeping the "guard", which validates the access with the security manager.
During this refactoring, also change
.items()
to validate each keys and values, like.keys()
and.values()
do.