Commit 4e9c0da2 authored by Aurel's avatar Aurel

update for SafeIter next

parent f9c89ebf
...@@ -106,8 +106,10 @@ def guarded_next(iterator, default=_marker): ...@@ -106,8 +106,10 @@ def guarded_next(iterator, default=_marker):
if default is _marker: if default is _marker:
raise raise
return default return default
BBB_ACCESS_CONTROL = False
if "next" not in safe_builtins: # BBB if "next" not in safe_builtins: # BBB
add_builtins(next=guarded_next) add_builtins(next=guarded_next)
BBB_ACCESS_CONTROL = True
_safe_class_attribute_dict = {} _safe_class_attribute_dict = {}
import inspect import inspect
...@@ -164,8 +166,8 @@ class TypeAccessChecker: ...@@ -164,8 +166,8 @@ class TypeAccessChecker:
ContainerAssertions[type] = TypeAccessChecker() ContainerAssertions[type] = TypeAccessChecker()
if BBB_ACCESS_CONTROL:
class SafeIterItems(SafeIter): class SafeIterItems(SafeIter):
def next(self): def next(self):
ob = self._next() ob = self._next()
...@@ -173,6 +175,15 @@ class SafeIterItems(SafeIter): ...@@ -173,6 +175,15 @@ class SafeIterItems(SafeIter):
guard(c, ob[0]) guard(c, ob[0])
guard(c, ob[1]) guard(c, ob[1])
return ob return ob
else:
class SafeIterItems(SafeIter):
def next(self):
ob = next(self._iter)
c = self.container
guard(c, ob[0])
guard(c, ob[1])
return ob
def get_iteritems(c, name): def get_iteritems(c, name):
return lambda: SafeIterItems(c.iteritems(), c) return lambda: SafeIterItems(c.iteritems(), c)
......
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