Commit 3341a43f authored by Jérome Perrin's avatar Jérome Perrin

patches/Restricted: fix reversed safe builtin

It did not allow iteration, probably since python 2.7.
We also need to allow objects implementing __reversed__ with a custom
type, I only found list.__reversed__
parent bcc93a72
......@@ -134,6 +134,9 @@ safe_builtins['sorted'] = guarded_sorted
def guarded_reversed(seq):
return SafeIter(reversed(seq))
safe_builtins['reversed'] = guarded_reversed
ContainerAssertions[reversed] = 1
# listreverseiterator is a special type, returned by list.__reversed__
ContainerAssertions[type(reversed([]))] = 1
def guarded_enumerate(seq, start=0):
return NullIter(enumerate(guarded_iter(seq), start=start))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment