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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 4629713d2dba92be81599c3c6f9bd0839d19e759
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:six-misc
Merge into: launchpad:master
Diff against target: 164 lines (+19/-16)
6 files modified
lib/lp/buildmaster/tests/mock_slaves.py (+3/-3)
lib/lp/code/model/tests/test_diff.py (+2/-1)
lib/lp/scripts/utilities/importpedant.py (+4/-3)
lib/lp/services/config/doc/canonical-config.txt (+2/-1)
lib/lp/services/tests/test_timeout.py (+6/-7)
lib/lp/testing/yuixhr.py (+2/-1)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+386912@code.launchpad.net

Commit message

Handle several standard library changes using six

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/buildmaster/tests/mock_slaves.py b/lib/lp/buildmaster/tests/mock_slaves.py
2index 9c99137..df48937 100644
3--- a/lib/lp/buildmaster/tests/mock_slaves.py
4+++ b/lib/lp/buildmaster/tests/mock_slaves.py
5@@ -23,10 +23,10 @@ __all__ = [
6
7 import os
8 import sys
9-import types
10
11 import fixtures
12 from lpbuildd.tests.harness import BuilddSlaveTestSetup
13+import six
14 from six.moves import xmlrpc_client
15 from testtools.content import Content
16 from testtools.content_type import UTF8_TEXT
17@@ -173,7 +173,7 @@ class BuildingSlave(OkSlave):
18 def getFile(self, sum, file_to_write):
19 self.call_log.append('getFile')
20 if sum == "buildlog":
21- if isinstance(file_to_write, types.StringTypes):
22+ if isinstance(file_to_write, six.string_types):
23 file_to_write = open(file_to_write, 'wb')
24 file_to_write.write("This is a build log")
25 file_to_write.close()
26@@ -212,7 +212,7 @@ class WaitingSlave(OkSlave):
27 def getFile(self, hash, file_to_write):
28 self.call_log.append('getFile')
29 if hash in self.valid_files:
30- if isinstance(file_to_write, types.StringTypes):
31+ if isinstance(file_to_write, six.string_types):
32 file_to_write = open(file_to_write, 'wb')
33 if not self.valid_files[hash]:
34 content = b"This is a %s" % hash
35diff --git a/lib/lp/code/model/tests/test_diff.py b/lib/lp/code/model/tests/test_diff.py
36index 70f0866..8eaeeab 100644
37--- a/lib/lp/code/model/tests/test_diff.py
38+++ b/lib/lp/code/model/tests/test_diff.py
39@@ -18,6 +18,7 @@ from breezy.patches import (
40 parse_patches,
41 RemoveLine,
42 )
43+from six.moves import reload_module
44 from testtools.matchers import (
45 Equals,
46 Is,
47@@ -572,7 +573,7 @@ class TestPreviewDiff(DiffTestCase):
48
49 def test_fromBranchMergeProposal_does_not_warn_on_conflicts(self):
50 """PreviewDiff generation emits no conflict warnings."""
51- reload(trace)
52+ reload_module(trace)
53 bmp, source_rev_id, target_rev_id = self.createExampleBzrMerge()
54 handler = RecordLister()
55 logger = logging.getLogger('brz')
56diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
57index a53a008..bae2269 100644
58--- a/lib/lp/scripts/utilities/importpedant.py
59+++ b/lib/lp/scripts/utilities/importpedant.py
60@@ -3,14 +3,15 @@
61
62 from __future__ import absolute_import, print_function, unicode_literals
63
64-import __builtin__
65 import atexit
66 import itertools
67 from operator import attrgetter
68 import types
69
70+from six.moves import builtins
71
72-original_import = __builtin__.__import__
73+
74+original_import = builtins.__import__
75 naughty_imports = set()
76
77 # Silence bogus warnings from Hardy's python-pkg-resources package.
78@@ -321,5 +322,5 @@ def report_naughty_imports():
79
80
81 def install_import_pedant():
82- __builtin__.__import__ = import_pedant
83+ builtins.__import__ = import_pedant
84 atexit.register(report_naughty_imports)
85diff --git a/lib/lp/services/config/doc/canonical-config.txt b/lib/lp/services/config/doc/canonical-config.txt
86index bece921..7bb4575 100644
87--- a/lib/lp/services/config/doc/canonical-config.txt
88+++ b/lib/lp/services/config/doc/canonical-config.txt
89@@ -215,7 +215,8 @@ argument to the constructor.
90 # >>> os.environ[DEFAULT_SECTION] = 'default'
91
92 # # reload the LaunchpadConfig class object.
93-# >>> config_module = reload(lp.services.config)
94+# >>> from six.moves import reload_module
95+# >>> config_module = reload_module(lp.services.config)
96 # >>> from lp.services.config import config
97 # >>> config.filename
98 # '.../configs/mailman-itests/launchpad-lazr.conf'
99diff --git a/lib/lp/services/tests/test_timeout.py b/lib/lp/services/tests/test_timeout.py
100index 55db5bb..c0dd217 100644
101--- a/lib/lp/services/tests/test_timeout.py
102+++ b/lib/lp/services/tests/test_timeout.py
103@@ -6,10 +6,6 @@
104
105 __metaclass__ = type
106
107-from SimpleXMLRPCServer import (
108- SimpleXMLRPCRequestHandler,
109- SimpleXMLRPCServer,
110- )
111 import socket
112 from textwrap import dedent
113 import threading
114@@ -23,7 +19,10 @@ from requests.exceptions import (
115 ConnectionError,
116 InvalidSchema,
117 )
118-from six.moves import xmlrpc_client
119+from six.moves import (
120+ xmlrpc_client,
121+ xmlrpc_server,
122+ )
123 from testtools.matchers import (
124 ContainsDict,
125 Equals,
126@@ -56,7 +55,7 @@ def no_default_timeout():
127 pass
128
129
130-class EchoOrWaitXMLRPCReqHandler(SimpleXMLRPCRequestHandler):
131+class EchoOrWaitXMLRPCReqHandler(xmlrpc_server.SimpleXMLRPCRequestHandler):
132 """The request handler will respond to 'echo' requests normally but will
133 hang indefinitely for all other requests. This allows us to show a
134 successful request followed by one that times out.
135@@ -70,7 +69,7 @@ class EchoOrWaitXMLRPCReqHandler(SimpleXMLRPCRequestHandler):
136 self.connection.recv(1024)
137
138
139-class MySimpleXMLRPCServer(SimpleXMLRPCServer):
140+class MySimpleXMLRPCServer(xmlrpc_server.SimpleXMLRPCServer):
141 """Create a simple XMLRPC server to listen for requests."""
142 allow_reuse_address = True
143
144diff --git a/lib/lp/testing/yuixhr.py b/lib/lp/testing/yuixhr.py
145index 8a601e8..a4e566a 100644
146--- a/lib/lp/testing/yuixhr.py
147+++ b/lib/lp/testing/yuixhr.py
148@@ -24,6 +24,7 @@ from lazr.restful import ResourceJSONEncoder
149 from lazr.restful.utils import get_current_browser_request
150 import scandir
151 import simplejson
152+from six.moves import reload_module
153 from zope.component import getUtility
154 from zope.exceptions.exceptionformatter import format_exception
155 from zope.interface import implementer
156@@ -385,7 +386,7 @@ class YUITestFixtureControllerView(LaunchpadView):
157 module = sys.modules.get(self.module_name)
158 if module is not None:
159 del module._fixtures_
160- reload(module)
161+ reload_module(module)
162 return self.page_template % dict(
163 test_module='/+yuitest/%s.js' % self.traversed_path,
164 test_namespace=self.traversed_path.replace('/', '.'),

Subscribers

People subscribed via source and target branches

to status/vote changes: