[Zope3-checkins] CVS: Zope3/lib/python/Zope/Security - Checker.py:1.6

Guido van Rossum guido@python.org
Tue, 13 Aug 2002 12:11:51 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/Security
In directory cvs.zope.org:/tmp/cvs-serv9002

Modified Files:
	Checker.py 
Log Message:
A workaround to make sure that we allow the next() method on the
default 'iterator' object type.


=== Zope3/lib/python/Zope/Security/Checker.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/Security/Checker.py:1.5	Thu Jun 13 04:40:17 2002
+++ Zope3/lib/python/Zope/Security/Checker.py	Tue Aug 13 12:11:50 2002
@@ -288,6 +288,10 @@
     type(not 1): NoProxy, # Boolean, if available :)
 }
 
+class _Sequence(object):
+    def __len__(self): return 0
+    def __getitem__(self, i): raise IndexError
+
 _default_checkers = {
     dict: NamesChecker(['__getitem__', '__len__', '__iter__',
                         'get', 'has_key', '__copy__',
@@ -311,6 +315,7 @@
     types.ModuleType: _moduleChecker,
     type(iter([])): NamesChecker(['next']), # same types in Python 2.2.1,
     type(iter(())): NamesChecker(['next']), # different in Python 2.3
+    type(iter(_Sequence())): NamesChecker(['next']),
     type(Interface): _interfaceChecker,
     }