← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-sort-keys into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-sort-keys into launchpad:master.

Commit message:
Fix various sort key functions for Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

None isn't comparable with strings in Python 3, so for null cases either (a) use the empty string instead or (b) leave it out entirely if tuple comparison rules mean it's never relevant.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-sort-keys into launchpad:master.
diff --git a/lib/lp/bugs/model/bugtask.py b/lib/lp/bugs/model/bugtask.py
index 82caf37..4cd5a7b 100644
--- a/lib/lp/bugs/model/bugtask.py
+++ b/lib/lp/bugs/model/bugtask.py
@@ -151,11 +151,11 @@ def bugtask_sort_key(bugtask):
           - distro tasks, followed by their distroseries tasks
           - ubuntu first among the distros
     """
-    product_name = None
-    productseries_name = None
-    distribution_name = None
-    distroseries_name = None
-    sourcepackage_name = None
+    product_name = ''
+    productseries_name = ''
+    distribution_name = ''
+    distroseries_name = ''
+    sourcepackage_name = ''
 
     if bugtask.product:
         product_name = bugtask.product.name
diff --git a/lib/lp/registry/model/pillar.py b/lib/lp/registry/model/pillar.py
index 327b595..8bfc356 100644
--- a/lib/lp/registry/model/pillar.py
+++ b/lib/lp/registry/model/pillar.py
@@ -73,8 +73,8 @@ def pillar_sort_key(pillar):
           - products first, alphabetically
           - distributions, with ubuntu first and the rest alphabetically
     """
-    product_name = None
-    distribution_name = None
+    product_name = ''
+    distribution_name = ''
     if IProduct.providedBy(pillar):
         product_name = pillar.name
     elif IDistribution.providedBy(pillar):
diff --git a/lib/lp/snappy/vocabularies.py b/lib/lp/snappy/vocabularies.py
index ea88db2..80e8cd3 100644
--- a/lib/lp/snappy/vocabularies.py
+++ b/lib/lp/snappy/vocabularies.py
@@ -102,13 +102,13 @@ def sorting_tuple_date_created(element):
         else:
             return (1, element.distro_series.distribution.display_name,
                     (-seconds_since_epoch(element.distro_series.date_created)),
-                    None)
+                    0)
     else:
         if element.snappy_series is not None:
-            return (0, None, None,
+            return (0,
                     (-seconds_since_epoch(element.snappy_series.date_created)))
         else:
-            return 0, None, None, None
+            return 0, 0
 
 
 class SnappyDistroSeriesVocabulary(StormVocabularyBase):
diff --git a/lib/lp/soyuz/stories/webservice/xx-archive.txt b/lib/lp/soyuz/stories/webservice/xx-archive.txt
index 0b07995..8e2ddc6 100644
--- a/lib/lp/soyuz/stories/webservice/xx-archive.txt
+++ b/lib/lp/soyuz/stories/webservice/xx-archive.txt
@@ -246,9 +246,9 @@ archive.  First, define some general helper functions.
     >>> def permission_entry_sort_key(entry):
     ...      return (entry['permission'],
     ...              entry['person_link'],
-    ...              entry['component_name'],
-    ...              entry['source_package_name'],
-    ...              entry['pocket']),
+    ...              entry['component_name'] or '',
+    ...              entry['source_package_name'] or '',
+    ...              entry['pocket'] or ''),
 
     >>> def show_permission_entries(permissions):
     ...     for entry in sorted(permissions['entries'],