← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/range-iterator into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/range-iterator into lp:launchpad.

Commit message:
Prepare for range returning an iterator in Python 3.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/range-iterator/+merge/337043
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/range-iterator into lp:launchpad.
=== modified file 'lib/lp/app/browser/tests/launchpad-search-pages.txt'
--- lib/lp/app/browser/tests/launchpad-search-pages.txt	2016-01-26 15:47:37 +0000
+++ lib/lp/app/browser/tests/launchpad-search-pages.txt	2018-02-02 10:37:18 +0000
@@ -683,7 +683,7 @@
 Even if the PageMatch object to have an impossibly large size, the
 navigator conforms to Google's maximum size of 20.
 
-    >>> matches = range(0, 100)
+    >>> matches = list(range(0, 100))
     >>> page_matches._matches = matches
     >>> page_matches.start = 0
     >>> page_matches.total = 100
@@ -703,7 +703,7 @@
 the PageMatches object, so only 3 are yielded. The start of the next
 batch is 20, which is the start of the next batch from Google.
 
-    >>> matches = range(0, 3)
+    >>> matches = list(range(0, 3))
     >>> page_matches._matches = matches
     >>> navigator = GoogleBatchNavigator(
     ...     page_matches, search_view.request, page_matches.start, size=100)

=== modified file 'lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py'
--- lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py	2012-01-17 21:45:24 +0000
+++ lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test the populate-distroseriesdiff script."""
@@ -521,15 +521,15 @@
         self.assertFalse(self.makeFixer([1]).isDone())
 
     def test_cutChunk_one_cuts_exactly_one(self):
-        fixer = self.makeFixer(range(3))
+        fixer = self.makeFixer(list(range(3)))
         chunk = fixer._cutChunk(1)
         self.assertEqual([0], chunk)
         self.assertEqual(3 - 1, len(fixer.ids))
 
     def test_cutChunk_over_remaining_size_completes_loop(self):
-        fixer = self.makeFixer(range(3))
+        fixer = self.makeFixer(list(range(3)))
         chunk = fixer._cutChunk(100)
-        self.assertContentEqual(range(3), chunk)
+        self.assertContentEqual(list(range(3)), chunk)
         self.assertEqual([], fixer.ids)
 
     def test_updatesBaseVersion(self):

=== modified file 'lib/lp/services/database/doc/decoratedresultset.txt'
--- lib/lp/services/database/doc/decoratedresultset.txt	2014-01-13 11:42:59 +0000
+++ lib/lp/services/database/doc/decoratedresultset.txt	2018-02-02 10:37:18 +0000
@@ -163,7 +163,7 @@
     ...         pass
     ...     def copy(self, *args, **kwargs):
     ...         return FakeResultSet(self)
-    >>> rs = FakeResultSet(range(1,5))
+    >>> rs = FakeResultSet(list(range(1, 5)))
     >>> def my_pih(result_set):
     ...     print('this should run once only, count: %s' % len(result_set))
     >>> def my_deco(result):

=== modified file 'lib/lp/services/database/doc/multitablecopy.txt'
--- lib/lp/services/database/doc/multitablecopy.txt	2011-12-30 06:47:17 +0000
+++ lib/lp/services/database/doc/multitablecopy.txt	2018-02-02 10:37:18 +0000
@@ -25,7 +25,7 @@
     >>> tables_to_clean_up.append('textual')
     >>> cur.execute(
     ...     "CREATE TABLE textual (id SERIAL PRIMARY KEY, t varchar)")
-    >>> numeric_values = range(1,4)
+    >>> numeric_values = list(range(1, 4))
     >>> textual_values = ['one', 'two', 'three']
     >>> for number in numeric_values:
     ...     cur.execute("INSERT INTO numeric (n) VALUES (%d)" % number)

=== modified file 'lib/lp/services/feeds/tests/helper.py'
--- lib/lp/services/feeds/tests/helper.py	2015-10-14 15:22:01 +0000
+++ lib/lp/services/feeds/tests/helper.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Helper functions for testing feeds."""
@@ -121,9 +121,9 @@
                 # which column contains the error.
                 max_line_length = 66
                 wrapped_column_number = column_number % max_line_length
-                line_number_range = range(
+                line_number_range = list(range(
                     max(error_line_number - 2, 1),
-                    min(error_line_number + 3, len(lines)))
+                    min(error_line_number + 3, len(lines))))
                 for line_number in line_number_range:
                     unicode_line = unicode(
                         lines[line_number - 1], 'ascii', 'replace')

=== modified file 'lib/lp/services/webapp/tests/test_batching.py'
--- lib/lp/services/webapp/tests/test_batching.py	2018-01-02 16:10:26 +0000
+++ lib/lp/services/webapp/tests/test_batching.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -635,7 +635,7 @@
 
     def test_ShadowedList__init(self):
         # ShadowedList instances need two lists as constructor parametrs.
-        list1 = range(3)
+        list1 = list(range(3))
         list2 = self.makeStringSequence(list1)
         shadowed_list = ShadowedList(list1, list2)
         self.assertEqual(shadowed_list.values, list1)
@@ -643,24 +643,25 @@
 
     def test_ShadowedList__init__non_sequence_parameter(self):
         # values and shadow_values must be sequences.
-        self.assertRaises(TypeError, ShadowedList, 1, range(3))
-        self.assertRaises(TypeError, ShadowedList, range(3), 1)
+        self.assertRaises(TypeError, ShadowedList, 1, list(range(3)))
+        self.assertRaises(TypeError, ShadowedList, list(range(3)), 1)
 
     def test_ShadowedList__init__different_list_lengths(self):
         # values and shadow_values must have the same length.
-        self.assertRaises(ValueError, ShadowedList, range(2), range(3))
+        self.assertRaises(
+            ValueError, ShadowedList, list(range(2)), list(range(3)))
 
     def test_ShadowedList__len(self):
         # The length of a ShadowedList ist the same as the list of
         # the sequences it stores.
-        list1 = range(3)
+        list1 = list(range(3))
         list2 = self.makeStringSequence(list1)
         self.assertEqual(len(list1), len(ShadowedList(list1, list2)))
 
     def test_ShadowedList__slice(self):
         # A slice of a ShadowedList contains the slices of its
         # values and shaow_values.
-        list1 = range(5)
+        list1 = list(range(5))
         list2 = self.makeStringSequence(list1)
         shadowed_list = ShadowedList(list1, list2)
         self.assertEqual(list1[2:4], shadowed_list[2:4].values)
@@ -668,18 +669,18 @@
 
     def test_ShadowedList__getitem(self):
         # Accessing a single element of a ShadowedList is equivalent to
-        # accessig an element of its values attribute.
-        list1 = range(3)
+        # accessing an element of its values attribute.
+        list1 = list(range(3))
         list2 = self.makeStringSequence(list1)
         shadowed_list = ShadowedList(list1, list2)
         self.assertEqual(list1[1], shadowed_list[1])
 
     def test_ShadowedList__add(self):
-        # Two shadowedLists can be added, yielding another ShadowedList.
-        list1 = range(3)
+        # Two ShadowedLists can be added, yielding another ShadowedList.
+        list1 = list(range(3))
         list2 = self.makeStringSequence(list1)
         shadow_list1 = ShadowedList(list1, list2)
-        list3 = range(4)
+        list3 = list(range(4))
         list4 = self.makeStringSequence(list3)
         shadow_list2 = ShadowedList(list3, list4)
         list_sum = shadow_list1 + shadow_list2
@@ -689,14 +690,14 @@
 
     def test_ShadowedList__iterator(self):
         # Iterating over a ShadowedList yields if values elements.
-        list1 = range(3)
+        list1 = list(range(3))
         list2 = self.makeStringSequence(list1)
         shadow_list = ShadowedList(list1, list2)
         self.assertEqual(list1, list(iter(shadow_list)))
 
     def test_ShadowedList__reverse(self):
         # ShadowList.reverse() reverses its elements.
-        list1 = range(3)
+        list1 = list(range(3))
         list2 = self.makeStringSequence(list1)
         first1 = list1[0]
         last1 = list1[-1]
@@ -712,7 +713,7 @@
     def test_ShadowedList__reverse__values_and_shadow_values_identical(self):
         # ShadowList.reverse() works also when passed the same
         # sequence as values and as shadow_values.
-        list_ = range(3)
+        list_ = list(range(3))
         shadow_list = ShadowedList(list_, list_)
         shadow_list.reverse()
         self.assertEqual(0, shadow_list[-1])

=== modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py'
--- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2018-01-02 16:10:26 +0000
+++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2011-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2011-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test `DistroSeriesDifferenceJob` and utility."""
@@ -407,7 +407,7 @@
             dsp.parent_series, pocket=PackagePublishingPocket.RELEASE)
         spn = spph.sourcepackagerelease.sourcepackagename
 
-        create_jobs = range(1, 3)
+        create_jobs = list(range(1, 3))
         for counter in create_jobs:
             self.getJobSource().createForSPPHs([spph])
 

=== modified file 'lib/lp/translations/browser/tests/test_translationmessage_view.py'
--- lib/lp/translations/browser/tests/test_translationmessage_view.py	2016-02-05 16:51:12 +0000
+++ lib/lp/translations/browser/tests/test_translationmessage_view.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 from __future__ import with_statement
@@ -416,7 +416,7 @@
             revert_unselected_translations(translations, None, [0]))
 
     def test_revert_unselected_translations_handles_plurals(self):
-        translated_forms = range(3)
+        translated_forms = list(range(3))
         translations = dict(
             (form, self.getUniqueString()) for form in translated_forms)
 

=== modified file 'lib/lp/translations/browser/translationmessage.py'
--- lib/lp/translations/browser/translationmessage.py	2015-07-08 16:05:11 +0000
+++ lib/lp/translations/browser/translationmessage.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """View classes for ITranslationMessage interface."""
@@ -1067,7 +1067,7 @@
         # suggestion_blocks dictionary, keyed on plural form index; this
         # allows us later to just iterate over them in the view code
         # using a generic template.
-        self.pluralform_indices = range(self.context.plural_forms)
+        self.pluralform_indices = list(range(self.context.plural_forms))
 
         self._buildAllSuggestions()
 

=== modified file 'lib/lp/translations/model/potmsgset.py'
--- lib/lp/translations/model/potmsgset.py	2015-07-08 16:05:11 +0000
+++ lib/lp/translations/model/potmsgset.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -567,8 +567,8 @@
                 clauses.append('msgstr%s=%s' % (
                     sqlvalues(pluralform, potranslations[pluralform])))
 
-        remaining_plural_forms = range(
-            pofile.plural_forms, TranslationConstants.MAX_PLURAL_FORMS)
+        remaining_plural_forms = list(range(
+            pofile.plural_forms, TranslationConstants.MAX_PLURAL_FORMS))
 
         # Prefer either shared or diverged messages, depending on
         # arguments.

=== modified file 'lib/lp/translations/utilities/pluralforms.py'
--- lib/lp/translations/utilities/pluralforms.py	2015-10-14 16:23:18 +0000
+++ lib/lp/translations/utilities/pluralforms.py	2018-02-02 10:37:18 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -40,7 +40,7 @@
             forms[form].append(number)
 
     found_forms = sorted(forms.keys())
-    if found_forms != range(expected_forms):
+    if found_forms != list(range(expected_forms)):
         raise BadPluralExpression(
             "Plural expression should produce forms 0..%d, "
             "but we found forms %s." % (expected_forms, found_forms))
@@ -108,7 +108,7 @@
             return identity_map
 
         # Is either result out of range?
-        valid_forms = range(TranslationConstants.MAX_PLURAL_FORMS)
+        valid_forms = list(range(TranslationConstants.MAX_PLURAL_FORMS))
         if first_form not in valid_forms or second_form not in valid_forms:
             return identity_map
 


Follow ups