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
1diff --git a/lib/lp/services/database/configure.zcml b/lib/lp/services/database/configure.zcml
2index 3795b28..48b6aa0 100644
3--- a/lib/lp/services/database/configure.zcml
4+++ b/lib/lp/services/database/configure.zcml
5@@ -14,7 +14,7 @@
6
7 <class class="lp.services.database.decoratedresultset.DecoratedResultSet">
8 <allow interface="storm.zope.interfaces.IResultSet" />
9- <allow attributes="__getslice__ get_plain_result_set" />
10+ <allow attributes="__getslice__ __len__ get_plain_result_set" />
11 </class>
12
13 </configure>

Subscribers

People subscribed via source and target branches

to status/vote changes: