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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: c1c601778ff02dd26e127551d2a4dd047affef5c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-decoratedresultset-len
Merge into: launchpad:master
Diff against target: 13 lines (+1/-1)
1 file modified
lib/lp/services/database/configure.zcml (+1/-1)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+392371@code.launchpad.net

Commit message

Allow DecoratedResultSet.__len__

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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 @@
1414
15 <class class="lp.services.database.decoratedresultset.DecoratedResultSet">15 <class class="lp.services.database.decoratedresultset.DecoratedResultSet">
16 <allow interface="storm.zope.interfaces.IResultSet" />16 <allow interface="storm.zope.interfaces.IResultSet" />
17 <allow attributes="__getslice__ get_plain_result_set" />17 <allow attributes="__getslice__ __len__ get_plain_result_set" />
18 </class>18 </class>
1919
20</configure>20</configure>

Subscribers

People subscribed via source and target branches

to status/vote changes: