← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Commit message:
Handle several standard library changes using six

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/386912
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:six-misc into launchpad:master.
diff --git a/lib/lp/buildmaster/tests/mock_slaves.py b/lib/lp/buildmaster/tests/mock_slaves.py
index 9c99137..df48937 100644
--- a/lib/lp/buildmaster/tests/mock_slaves.py
+++ b/lib/lp/buildmaster/tests/mock_slaves.py
@@ -23,10 +23,10 @@ __all__ = [
 
 import os
 import sys
-import types
 
 import fixtures
 from lpbuildd.tests.harness import BuilddSlaveTestSetup
+import six
 from six.moves import xmlrpc_client
 from testtools.content import Content
 from testtools.content_type import UTF8_TEXT
@@ -173,7 +173,7 @@ class BuildingSlave(OkSlave):
     def getFile(self, sum, file_to_write):
         self.call_log.append('getFile')
         if sum == "buildlog":
-            if isinstance(file_to_write, types.StringTypes):
+            if isinstance(file_to_write, six.string_types):
                 file_to_write = open(file_to_write, 'wb')
             file_to_write.write("This is a build log")
             file_to_write.close()
@@ -212,7 +212,7 @@ class WaitingSlave(OkSlave):
     def getFile(self, hash, file_to_write):
         self.call_log.append('getFile')
         if hash in self.valid_files:
-            if isinstance(file_to_write, types.StringTypes):
+            if isinstance(file_to_write, six.string_types):
                 file_to_write = open(file_to_write, 'wb')
             if not self.valid_files[hash]:
                 content = b"This is a %s" % hash
diff --git a/lib/lp/code/model/tests/test_diff.py b/lib/lp/code/model/tests/test_diff.py
index 70f0866..8eaeeab 100644
--- a/lib/lp/code/model/tests/test_diff.py
+++ b/lib/lp/code/model/tests/test_diff.py
@@ -18,6 +18,7 @@ from breezy.patches import (
     parse_patches,
     RemoveLine,
     )
+from six.moves import reload_module
 from testtools.matchers import (
     Equals,
     Is,
@@ -572,7 +573,7 @@ class TestPreviewDiff(DiffTestCase):
 
     def test_fromBranchMergeProposal_does_not_warn_on_conflicts(self):
         """PreviewDiff generation emits no conflict warnings."""
-        reload(trace)
+        reload_module(trace)
         bmp, source_rev_id, target_rev_id = self.createExampleBzrMerge()
         handler = RecordLister()
         logger = logging.getLogger('brz')
diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
index a53a008..bae2269 100644
--- a/lib/lp/scripts/utilities/importpedant.py
+++ b/lib/lp/scripts/utilities/importpedant.py
@@ -3,14 +3,15 @@
 
 from __future__ import absolute_import, print_function, unicode_literals
 
-import __builtin__
 import atexit
 import itertools
 from operator import attrgetter
 import types
 
+from six.moves import builtins
 
-original_import = __builtin__.__import__
+
+original_import = builtins.__import__
 naughty_imports = set()
 
 # Silence bogus warnings from Hardy's python-pkg-resources package.
@@ -321,5 +322,5 @@ def report_naughty_imports():
 
 
 def install_import_pedant():
-    __builtin__.__import__ = import_pedant
+    builtins.__import__ = import_pedant
     atexit.register(report_naughty_imports)
diff --git a/lib/lp/services/config/doc/canonical-config.txt b/lib/lp/services/config/doc/canonical-config.txt
index bece921..7bb4575 100644
--- a/lib/lp/services/config/doc/canonical-config.txt
+++ b/lib/lp/services/config/doc/canonical-config.txt
@@ -215,7 +215,8 @@ argument to the constructor.
 #    >>> os.environ[DEFAULT_SECTION] = 'default'
 
 #    # reload the LaunchpadConfig class object.
-#    >>> config_module = reload(lp.services.config)
+#    >>> from six.moves import reload_module
+#    >>> config_module = reload_module(lp.services.config)
 #    >>> from lp.services.config import config
 #    >>> config.filename
 #    '.../configs/mailman-itests/launchpad-lazr.conf'
diff --git a/lib/lp/services/tests/test_timeout.py b/lib/lp/services/tests/test_timeout.py
index 55db5bb..c0dd217 100644
--- a/lib/lp/services/tests/test_timeout.py
+++ b/lib/lp/services/tests/test_timeout.py
@@ -6,10 +6,6 @@
 
 __metaclass__ = type
 
-from SimpleXMLRPCServer import (
-    SimpleXMLRPCRequestHandler,
-    SimpleXMLRPCServer,
-    )
 import socket
 from textwrap import dedent
 import threading
@@ -23,7 +19,10 @@ from requests.exceptions import (
     ConnectionError,
     InvalidSchema,
     )
-from six.moves import xmlrpc_client
+from six.moves import (
+    xmlrpc_client,
+    xmlrpc_server,
+    )
 from testtools.matchers import (
     ContainsDict,
     Equals,
@@ -56,7 +55,7 @@ def no_default_timeout():
     pass
 
 
-class EchoOrWaitXMLRPCReqHandler(SimpleXMLRPCRequestHandler):
+class EchoOrWaitXMLRPCReqHandler(xmlrpc_server.SimpleXMLRPCRequestHandler):
     """The request handler will respond to 'echo' requests normally but will
     hang indefinitely for all other requests.  This allows us to show a
     successful request followed by one that times out.
@@ -70,7 +69,7 @@ class EchoOrWaitXMLRPCReqHandler(SimpleXMLRPCRequestHandler):
             self.connection.recv(1024)
 
 
-class MySimpleXMLRPCServer(SimpleXMLRPCServer):
+class MySimpleXMLRPCServer(xmlrpc_server.SimpleXMLRPCServer):
     """Create a simple XMLRPC server to listen for requests."""
     allow_reuse_address = True
 
diff --git a/lib/lp/testing/yuixhr.py b/lib/lp/testing/yuixhr.py
index 8a601e8..a4e566a 100644
--- a/lib/lp/testing/yuixhr.py
+++ b/lib/lp/testing/yuixhr.py
@@ -24,6 +24,7 @@ from lazr.restful import ResourceJSONEncoder
 from lazr.restful.utils import get_current_browser_request
 import scandir
 import simplejson
+from six.moves import reload_module
 from zope.component import getUtility
 from zope.exceptions.exceptionformatter import format_exception
 from zope.interface import implementer
@@ -385,7 +386,7 @@ class YUITestFixtureControllerView(LaunchpadView):
             module = sys.modules.get(self.module_name)
             if module is not None:
                 del module._fixtures_
-                reload(module)
+                reload_module(module)
         return self.page_template % dict(
             test_module='/+yuitest/%s.js' % self.traversed_path,
             test_namespace=self.traversed_path.replace('/', '.'),