← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-decoratedresultset-len into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-decoratedresultset-len into launchpad:master.

Commit message:
Allow DecoratedResultSet.__len__

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/392371

On Python 3, list() calls len() internally to preallocate the correct amount of space if possible.  If __len__ is unimplemented, then it falls back to guessing, but ForbiddenAttribute confuses it and results in failing to create the list.  Allowing __len__ through the security proxy, even though it's unimplemented, avoids this.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-decoratedresultset-len into launchpad:master.
diff --git a/lib/lp/services/database/configure.zcml b/lib/lp/services/database/configure.zcml
index 3795b28..48b6aa0 100644
--- a/lib/lp/services/database/configure.zcml
+++ b/lib/lp/services/database/configure.zcml
@@ -14,7 +14,7 @@
 
     <class class="lp.services.database.decoratedresultset.DecoratedResultSet">
         <allow interface="storm.zope.interfaces.IResultSet" />
-        <allow attributes="__getslice__ get_plain_result_set" />
+        <allow attributes="__getslice__ __len__ get_plain_result_set" />
     </class>
 
 </configure>