Repository navigation
Remove builtins which iterate without calling _getiter_ - #337
Merged
Merged
Conversation
…not added They iterate their argument in C, bypassing the _getiter_ guard. Refs #335
icemac
commented
Nov 2, 2026
icemac
added a commit
to zopefoundation/AccessControl
that referenced
this pull request
Nov 3, 2026
* Add guarded_sorted and guarded_tuple RestrictedPython 8.6 removes the unguarded sorted and tuple from safe_builtins, see zopefoundation/RestrictedPython#337. * Make guarded_tuple a class so isinstance(x, tuple) keeps working
dataflake
approved these changes
Nov 3, 2026
dataflake
left a comment
Member
There was a problem hiding this comment.
bytes is important and should get a wrapper in AccessControl
icemac
added a commit
to zopefoundation/AccessControl
that referenced
this pull request
Nov 3, 2026
RestrictedPython 8.6 removes the unguarded bytes from safe_builtins, see zopefoundation/RestrictedPython#337.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove
bytes,sorted,tupleandzipfromsafe_builtinsand document whyreversedis not added: all of them iterate their argument in C, so the_getiter_guard never runs. Confirmed with a refusing_getiter_: the comprehension is blocked whiletuple(secret),sorted(secret)and[x for x in zip(secret)]return every element.Refs #335, supersedes #336.
AccessControl.ZopeGuardsalready wrapszip. zopefoundation/AccessControl#174 addedguarded_sortedandguarded_tuple, zopefoundation/AccessControl#175 lets them accept generators and zopefoundation/AccessControl#176 addsguarded_bytes. All of them should be released before this.