[ZCM] [ZC] 1656/ 2 Comment "Loop over enumeration builtin broken"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Fri Jan 7 17:06:35 EST 2005


Issue #1656 Update (Comment) "Loop over enumeration builtin broken"
 Status Accepted, Zope/bug medium
To followup, visit:
  http://collector.zope.org/Zope/1656

==============================================================
= Comment - Entry #2 by evan on Jan 7, 2005 5:06 pm

Fixes checked into the 2.7 branch.  I don't have SVN access set up, so can someone else apply to HEAD and 2.8?
________________________________________
= Request - Entry #1 by evan on Jan 7, 2005 5:01 pm

 Status: Pending => Accepted

 Supporters added: evan

The following all fail for me (raising Unauthorized):

  iter((1,)).next()
  enumerate((1,)).next()
  for k in iter((1,)): pass
  for i, k in enumerate((1,)): pass

SafeIter's signature doesn't match the builtin iter() -- the second argument is "container" with default None.

The first 'for' loop double-wraps with SafeIter, and the second ends up wrapping a raw iterator, which validate() doesn't like.

I'm replacing SafeIter almost everywhere with a guarded_iter() that tests whether its argument is already a SafeIter or NullIter (this is used to mark an iterator as safe), and only wraps if it isn't.  This has the side benefit of not exposing the SafeIter class to restricted code.

Next, I'm adding a security declaration to allow access to SafeIter.next().
==============================================================



More information about the Zope-Collector-Monitor mailing list