← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Commit message:
Allow __len__ on several model classes

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

The reasoning is as in c1c601778ff02dd26e127551d2a4dd047affef5c (https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/392371): on Python 3, tuple() and list() call len() internally to preallocate the correct amount of space if possible.  If __len__ is unimplemented, then they fall back to guessing, but ForbiddenAttribute confuses them 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-allow-len into launchpad:master.
diff --git a/lib/lp/bugs/configure.zcml b/lib/lp/bugs/configure.zcml
index 3585d8d..aa9def2 100644
--- a/lib/lp/bugs/configure.zcml
+++ b/lib/lp/bugs/configure.zcml
@@ -431,13 +431,15 @@
         <class
             class="lp.bugs.model.bugtracker.BugTrackerSet">
             <allow
-                interface="lp.bugs.interfaces.bugtracker.IBugTrackerSet"/>
+                interface="lp.bugs.interfaces.bugtracker.IBugTrackerSet"
+                attributes="__len__"/>
         </class>
         <securedutility
             class="lp.bugs.model.bugtracker.BugTrackerSet"
             provides="lp.bugs.interfaces.bugtracker.IBugTrackerSet">
             <allow
-                interface="lp.bugs.interfaces.bugtracker.IBugTrackerSet"/>
+                interface="lp.bugs.interfaces.bugtracker.IBugTrackerSet"
+                attributes="__len__"/>
         </securedutility>
         <adapter
             provides="lp.services.webapp.interfaces.IBreadcrumb"
diff --git a/lib/lp/registry/configure.zcml b/lib/lp/registry/configure.zcml
index 659b8d9..7c2dad8 100644
--- a/lib/lp/registry/configure.zcml
+++ b/lib/lp/registry/configure.zcml
@@ -1934,13 +1934,15 @@
     <class
         class="lp.registry.model.distribution.DistributionSet">
         <allow
-            interface="lp.registry.interfaces.distribution.IDistributionSet"/>
+            interface="lp.registry.interfaces.distribution.IDistributionSet"
+            attributes="__len__"/>
     </class>
     <securedutility
         class="lp.registry.model.distribution.DistributionSet"
         provides="lp.registry.interfaces.distribution.IDistributionSet">
         <allow
-            interface="lp.registry.interfaces.distribution.IDistributionSet"/>
+            interface="lp.registry.interfaces.distribution.IDistributionSet"
+            attributes="__len__"/>
     </securedutility>
 
     <!-- SourcePackage -->
diff --git a/lib/lp/services/mail/configure.zcml b/lib/lp/services/mail/configure.zcml
index 08106ae..06e3ef0 100644
--- a/lib/lp/services/mail/configure.zcml
+++ b/lib/lp/services/mail/configure.zcml
@@ -10,7 +10,9 @@
     i18n_domain="launchpad">
 
     <class class="lp.services.mail.notificationrecipientset.NotificationRecipientSet">
-        <allow interface="lp.services.mail.interfaces.INotificationRecipientSet" />
+        <allow
+            interface="lp.services.mail.interfaces.INotificationRecipientSet"
+            attributes="__len__" />
     </class>
 
 </configure>
diff --git a/lib/lp/soyuz/configure.zcml b/lib/lp/soyuz/configure.zcml
index 643a85b..9de2236 100644
--- a/lib/lp/soyuz/configure.zcml
+++ b/lib/lp/soyuz/configure.zcml
@@ -276,13 +276,15 @@
     <class
         class="lp.soyuz.model.packagediff.PackageDiffSet">
         <allow
-            interface="lp.soyuz.interfaces.packagediff.IPackageDiffSet"/>
+            interface="lp.soyuz.interfaces.packagediff.IPackageDiffSet"
+            attributes="__len__"/>
     </class>
     <securedutility
         class="lp.soyuz.model.packagediff.PackageDiffSet"
         provides="lp.soyuz.interfaces.packagediff.IPackageDiffSet">
         <allow
-            interface="lp.soyuz.interfaces.packagediff.IPackageDiffSet"/>
+            interface="lp.soyuz.interfaces.packagediff.IPackageDiffSet"
+            attributes="__len__"/>
     </securedutility>
 
     <!-- ArchiveAuthToken -->
@@ -607,7 +609,8 @@
         <class
             class="lp.soyuz.model.distroarchseries.DistroArchSeries">
             <allow
-                interface="lp.soyuz.interfaces.distroarchseries.IDistroArchSeriesPublic"/>
+                interface="lp.soyuz.interfaces.distroarchseries.IDistroArchSeriesPublic"
+                attributes="__len__"/>
             <require
                 permission="launchpad.Admin"
                 set_schema="lp.soyuz.interfaces.distroarchseries.IDistroArchSeriesPublic"/>
diff --git a/lib/lp/translations/configure.zcml b/lib/lp/translations/configure.zcml
index 3693a4b..a5422e3 100644
--- a/lib/lp/translations/configure.zcml
+++ b/lib/lp/translations/configure.zcml
@@ -203,7 +203,8 @@
             class="lp.translations.model.translationimportqueue.TranslationImportQueue"
             provides="lp.translations.interfaces.translationimportqueue.ITranslationImportQueue">
             <allow
-                interface="lp.translations.interfaces.translationimportqueue.ITranslationImportQueue"/>
+                interface="lp.translations.interfaces.translationimportqueue.ITranslationImportQueue"
+                attributes="__len__"/>
         </securedutility>
     <class
         class="lp.translations.model.pofiletranslator.POFileTranslator">
@@ -375,7 +376,8 @@
         <class
             class="lp.translations.model.potemplate.POTemplate">
             <allow
-                interface="lp.translations.interfaces.potemplate.IPOTemplate"/>
+                interface="lp.translations.interfaces.potemplate.IPOTemplate"
+                attributes="__len__"/>
             <require
                 permission="launchpad.TranslationsAdmin"
                 set_attributes="