← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:six-integer-types into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:six-integer-types into launchpad:master.

Commit message:
Replace (int, long) with six.integer_types

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

Python 3 doesn't have a separate long type.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:six-integer-types into launchpad:master.
diff --git a/lib/lp/bugs/model/bugwatch.py b/lib/lp/bugs/model/bugwatch.py
index a9f430d..847fc50 100644
--- a/lib/lp/bugs/model/bugwatch.py
+++ b/lib/lp/bugs/model/bugwatch.py
@@ -16,6 +16,7 @@ from lazr.lifecycle.event import ObjectModifiedEvent
 from lazr.lifecycle.snapshot import Snapshot
 from lazr.uri import find_uris_in_text
 from pytz import utc
+import six
 from six.moves.urllib.parse import (
     splitvalue,
     urlunsplit,
@@ -110,7 +111,7 @@ def get_bug_watch_ids(references):
     for reference in references:
         if IBugWatch.providedBy(reference):
             yield reference.id
-        elif isinstance(reference, (int, long)):
+        elif isinstance(reference, six.integer_types):
             yield reference
         else:
             raise AssertionError(
diff --git a/lib/lp/bugs/scripts/checkwatches/core.py b/lib/lp/bugs/scripts/checkwatches/core.py
index e3c41f6..166376c 100644
--- a/lib/lp/bugs/scripts/checkwatches/core.py
+++ b/lib/lp/bugs/scripts/checkwatches/core.py
@@ -30,6 +30,7 @@ import threading
 import time
 
 import pytz
+import six
 from six.moves.xmlrpc_client import ProtocolError
 from twisted.internet import reactor
 from twisted.internet.defer import DeferredList
@@ -256,7 +257,7 @@ class CheckwatchesMaster(WorkingBase):
         """
         with self.transaction:
             # Get the bug tracker.
-            if isinstance(bug_tracker, (int, long)):
+            if isinstance(bug_tracker, six.integer_types):
                 bug_tracker = getUtility(IBugTrackerSet).get(bug_tracker)
             # Save the name and url for later, since we might need it
             # to report an error after a transaction has been aborted.
diff --git a/lib/lp/registry/interfaces/person.py b/lib/lp/registry/interfaces/person.py
index fd501e9..4306f87 100644
--- a/lib/lp/registry/interfaces/person.py
+++ b/lib/lp/registry/interfaces/person.py
@@ -68,6 +68,7 @@ from lazr.restful.fields import (
     Reference,
     )
 from lazr.restful.interface import copy_field
+import six
 from six.moves import http_client
 from zope.component import getUtility
 from zope.formlib.form import NoInputData
@@ -180,7 +181,7 @@ def validate_person_common(obj, attr, value, validate_func,
     """Validate the person using the supplied function."""
     if value is None:
         return None
-    assert isinstance(value, (int, long)), (
+    assert isinstance(value, six.integer_types), (
         "Expected int for Person foreign key reference, got %r" % type(value))
 
     # Importing here to avoid a cyclic import.
diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py
index 880365e..923d8af 100644
--- a/lib/lp/services/librarian/client.py
+++ b/lib/lp/services/librarian/client.py
@@ -224,7 +224,7 @@ class FileUploadClient:
 
             Store.of(content).flush()
 
-            assert isinstance(aliasID, (int, long)), \
+            assert isinstance(aliasID, six.integer_types), \
                     "aliasID %r not an integer" % (aliasID, )
             return aliasID
         finally:
diff --git a/lib/lp/services/librarianserver/librariangc.py b/lib/lp/services/librarianserver/librariangc.py
index cc536e8..ac2b630 100644
--- a/lib/lp/services/librarianserver/librariangc.py
+++ b/lib/lp/services/librarianserver/librariangc.py
@@ -14,6 +14,7 @@ import hashlib
 import multiprocessing.pool
 import os
 import re
+import six
 import sys
 from time import time
 
@@ -860,7 +861,7 @@ def delete_unwanted_swift_files(con):
 def get_file_path(content_id):
     """Return the physical file path to the matching LibraryFileContent id.
     """
-    assert isinstance(content_id, (int, long)), (
+    assert isinstance(content_id, six.integer_types), (
         'Invalid content_id %s' % repr(content_id))
     return os.path.join(get_storage_root(), relative_file_path(content_id))
 
diff --git a/lib/lp/services/librarianserver/swift.py b/lib/lp/services/librarianserver/swift.py
index db01746..5e60076 100644
--- a/lib/lp/services/librarianserver/swift.py
+++ b/lib/lp/services/librarianserver/swift.py
@@ -21,6 +21,7 @@ import re
 import time
 
 import scandir
+import six
 from six.moves.urllib.parse import quote
 from swiftclient import client as swiftclient
 
@@ -245,7 +246,7 @@ def swift_location(lfc_id):
     Per https://answers.launchpad.net/swift/+question/181977, we can't
     simply stuff everything into one container.
     '''
-    assert isinstance(lfc_id, (int, long)), 'Not a LibraryFileContent.id'
+    assert isinstance(lfc_id, six.integer_types), 'Not a LibraryFileContent.id'
 
     # Don't change this unless you are also going to rebuild the Swift
     # storage, as objects will no longer be found in the expected
diff --git a/lib/lp/services/librarianserver/testing/tests/test_fakelibrarian.py b/lib/lp/services/librarianserver/testing/tests/test_fakelibrarian.py
index 6e69979..c5dd2a3 100644
--- a/lib/lp/services/librarianserver/testing/tests/test_fakelibrarian.py
+++ b/lib/lp/services/librarianserver/testing/tests/test_fakelibrarian.py
@@ -7,6 +7,7 @@ __metaclass__ = type
 
 from StringIO import StringIO
 
+import six
 import transaction
 from transaction.interfaces import ISynchronizer
 from zope.component import getUtility
@@ -59,7 +60,7 @@ class LibraryAccessScenarioMixin:
 
     def test_insert_retrieve(self):
         name, text, alias = self._storeFile()
-        self.assertIsInstance(alias.id, (int, long))
+        self.assertIsInstance(alias.id, six.integer_types)
 
         transaction.commit()
 
@@ -99,7 +100,7 @@ class LibraryAccessScenarioMixin:
     def test_addFile_returns_alias_id(self):
         alias_id = getUtility(ILibrarianClient).addFile(
             'bar.txt', 3, StringIO('bar'), 'text/plain')
-        self.assertIsInstance(alias_id, (int, long))
+        self.assertIsInstance(alias_id, six.integer_types)
         self.assertIsInstance(
             getUtility(ILibraryFileAliasSet)[alias_id],
             LibraryFileAlias)
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 6c0492f..924bda8 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -2121,7 +2121,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
         """
         if bug is None:
             bug = self.makeBug()
-        elif isinstance(bug, (int, long, basestring)):
+        elif isinstance(bug, (six.integer_types, basestring)):
             bug = getUtility(IBugSet).getByNameOrID(str(bug))
         if owner is None:
             owner = self.makePerson()
@@ -2156,7 +2156,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
         """
         if bug is None:
             bug = self.makeBug()
-        elif isinstance(bug, (int, long, basestring)):
+        elif isinstance(bug, (six.integer_types, basestring)):
             bug = getUtility(IBugSet).getByNameOrID(str(bug))
         if owner is None:
             owner = self.makePerson()