← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-unicode-repr into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-unicode-repr into launchpad:master.

Commit message:
Handle different repr of Unicode objects in Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398085
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-unicode-repr into launchpad:master.
diff --git a/lib/lp/archivepublisher/tests/test_signing.py b/lib/lp/archivepublisher/tests/test_signing.py
index d431457..e59a3dd 100644
--- a/lib/lp/archivepublisher/tests/test_signing.py
+++ b/lib/lp/archivepublisher/tests/test_signing.py
@@ -2111,7 +2111,7 @@ class TestSigningUploadWithSigningService(TestSigningHelpers):
 
         self.assertIn(
             "INFO Skipping injection for key type UEFI: "
-            "not in [u'SIPL', u'OPAL']",
+            "not in %s" % ['SIPL', 'OPAL'],
             log_content)
 
     def test_fallback_skips_key_injection_for_existing_keys(self):
diff --git a/lib/lp/bugs/adapters/treelookup.py b/lib/lp/bugs/adapters/treelookup.py
index 3c35c22..c1b84f2 100644
--- a/lib/lp/bugs/adapters/treelookup.py
+++ b/lib/lp/bugs/adapters/treelookup.py
@@ -123,14 +123,14 @@ class LookupBranch:
         if self._describe_key_chars.issuperset(as_string):
             return as_string
         else:
-            return repr(key)
+            return repr(as_string)
 
     def _describe_result(self, result):
         """Return a pretty representation of the branch result.
 
         By default, return the representation as returned by `repr`.
         """
-        return repr(result)
+        return repr(str(result))
 
     def __repr__(self):
         """A machine-readable representation of this branch."""
diff --git a/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt b/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt
index 71589c2..89e5443 100644
--- a/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt
+++ b/lib/lp/bugs/doc/externalbugtracker-bugzilla.txt
@@ -30,7 +30,7 @@ UnparsableBugTrackerVersion is raised:
     ... # doctest: +IGNORE_EXCEPTION_MODULE_IN_PYTHON2
     Traceback (most recent call last):
       ...
-    lp.bugs.externalbugtracker.base.UnparsableBugTrackerVersion: Failed to parse version u'A.B' for http://...
+    lp.bugs.externalbugtracker.base.UnparsableBugTrackerVersion: Failed to parse version 'A.B' for http://...
 
 The version parsing is carried out by the Bugzilla._parseVersion()
 method, which takes a version string and returns a tuple of
diff --git a/lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt b/lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt
index 48f69b8..4103661 100644
--- a/lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt
+++ b/lib/lp/bugs/doc/externalbugtracker-trac-lp-plugin.txt
@@ -94,7 +94,7 @@ After it has been called, the XML-RPC transport will have its
 auth_cookie attribute set.
 
     >>> test_transport.cookie_jar
-    <RequestsCookieJar[Cookie(version=0, name=u'trac_auth'...
+    <RequestsCookieJar[Cookie(version=0, name=...'trac_auth'...
 
 The XML-RPC transport shares its cookiejar with the TracLPPlugin instance.
 This is so that the TracLPPlugin can use the cookiejar when authenticating
@@ -107,7 +107,7 @@ use, meaning that there's no need to manually manipulate cookies.
 So if we look in the TracLPPlugin's CookieJar we'll see the same cookie:
 
     >>> trac._cookie_jar
-    <RequestsCookieJar[Cookie(version=0, name=u'trac_auth'...
+    <RequestsCookieJar[Cookie(version=0, name=...'trac_auth'...
 
 And altering the cookie in the TracLPPlugin's CookieJar will mean, of
 course, that it's altered in the XML-RPC transport's CookieJar, too.
@@ -118,12 +118,12 @@ course, that it's altered in the XML-RPC transport's CookieJar, too.
     ...     domain='http://example.com', path='')
 
     >>> trac._cookie_jar
-    <...CookieJar[Cookie(version=0, name=u'trac_auth',
-    value=u'Look ma, a new cookie!'...>
+    <...CookieJar[Cookie(version=0, name=...'trac_auth',
+    value=...'Look ma, a new cookie!'...>
 
     >>> test_transport.cookie_jar
-    <...CookieJar[Cookie(version=0, name=u'trac_auth',
-    value=u'Look ma, a new cookie!'...>
+    <...CookieJar[Cookie(version=0, name=...'trac_auth',
+    value=...'Look ma, a new cookie!'...>
 
 If authentication fails, a BugTrackerAuthenticationError will be raised.
 
@@ -170,7 +170,7 @@ authentication. Because the cookie is now set, other calls won't cause
 an authorization request.
 
     >>> test_transport.auth_cookie
-    Cookie(version=0, name=u'trac_auth'...)
+    Cookie(version=0, name=...'trac_auth'...)
     >>> trac.getCurrentDBTime()
     datetime.datetime(2008, 4, 9, 2, 2, 1, tzinfo=<UTC>)
 
diff --git a/lib/lp/bugs/doc/treelookup.txt b/lib/lp/bugs/doc/treelookup.txt
index 46da657..a43b456 100644
--- a/lib/lp/bugs/doc/treelookup.txt
+++ b/lib/lp/bugs/doc/treelookup.txt
@@ -121,14 +121,14 @@ complete description of the tree you've created.
   >>> print(tree.describe())
   tree(
       branch(Snack => tree(
-          branch(u'Mars Bar', Snickers => u'Bad')
-          branch(Apple, Banana => u'Good')
+          branch('Mars Bar', Snickers => 'Bad')
+          branch(Apple, Banana => 'Good')
           ))
       branch(Lunch, Dinner => tree(
-          branch(u'Fish and chips', u"Penne all'arrabbiata" => u'Nice')
-          branch(u'Raw liver' => u'Not so nice')
+          branch('Fish and chips', "Penne all'arrabbiata" => 'Nice')
+          branch('Raw liver' => 'Not so nice')
           ))
-      branch(* => u'Make up your mind!')
+      branch(* => 'Make up your mind!')
       )
 
 We can also see that the result of constructing a new lookup using an
@@ -136,16 +136,16 @@ existing one is the same as if we had constructed it independently.
 
   >>> print(breakfast_tree.describe())
   tree(
-      branch(Breakfast => u'Corn flakes')
+      branch(Breakfast => 'Corn flakes')
       branch(Snack => tree(
-          branch(u'Mars Bar', Snickers => u'Bad')
-          branch(Apple, Banana => u'Good')
+          branch('Mars Bar', Snickers => 'Bad')
+          branch(Apple, Banana => 'Good')
           ))
       branch(Lunch, Dinner => tree(
-          branch(u'Fish and chips', u"Penne all'arrabbiata" => u'Nice')
-          branch(u'Raw liver' => u'Not so nice')
+          branch('Fish and chips', "Penne all'arrabbiata" => 'Nice')
+          branch('Raw liver' => 'Not so nice')
           ))
-      branch(* => u'Make up your mind!')
+      branch(* => 'Make up your mind!')
       )
 
 Simple keys are shown without quotes, to aid readability, and default
@@ -173,10 +173,10 @@ branches with keys are candidates for being discarded.
   ...     )
   >>> print(pruned_tree.describe())
   tree(
-      branch(Snack => u'Crisps')
-      branch(Lunch => u'Bread')
-      branch(Dinner => u'Soup')
-      branch(* => u'Eat more fruit and veg')
+      branch(Snack => 'Crisps')
+      branch(Lunch => 'Bread')
+      branch(Dinner => 'Soup')
+      branch(* => 'Eat more fruit and veg')
       )
 
 
@@ -196,10 +196,9 @@ leaves.
   >>> for elems in tree.flatten():
   ...     path, result = elems[:-1], elems[-1]
   ...     print(' => '.join(
-  ...         [repr(node.keys) for node in path] + [repr(result)]))
-  (u'Snack',) => (u'Mars Bar', u'Snickers') => u'Bad'
-  (u'Snack',) => (u'Apple', u'Banana') => u'Good'
-  (u'Lunch', u'Dinner') =>
-      (u'Fish and chips', u"Penne all'arrabbiata") => u'Nice'
-  (u'Lunch', u'Dinner') => (u'Raw liver',) => u'Not so nice'
-  () => u'Make up your mind!'
+  ...         [pretty(node.keys) for node in path] + [pretty(result)]))
+  ('Snack',) => ('Mars Bar', 'Snickers') => 'Bad'
+  ('Snack',) => ('Apple', 'Banana') => 'Good'
+  ('Lunch', 'Dinner') => ('Fish and chips', "Penne all'arrabbiata") => 'Nice'
+  ('Lunch', 'Dinner') => ('Raw liver',) => 'Not so nice'
+  () => 'Make up your mind!'
diff --git a/lib/lp/bugs/externalbugtracker/bugzilla.py b/lib/lp/bugs/externalbugtracker/bugzilla.py
index 9cd6ce3..8f9c1d4 100644
--- a/lib/lp/bugs/externalbugtracker/bugzilla.py
+++ b/lib/lp/bugs/externalbugtracker/bugzilla.py
@@ -242,7 +242,7 @@ class Bugzilla(ExternalBugTracker):
         version_numbers = re.findall('[0-9]+', version)
         if len(version_numbers) == 0:
             raise UnparsableBugTrackerVersion(
-                'Failed to parse version %r for %s' %
+                "Failed to parse version '%s' for %s" %
                 (version, self.baseurl))
 
         return tuple(int(number) for number in version_numbers)
diff --git a/lib/lp/bugs/model/tests/test_bugtask.py b/lib/lp/bugs/model/tests/test_bugtask.py
index f2d4044..527120e 100644
--- a/lib/lp/bugs/model/tests/test_bugtask.py
+++ b/lib/lp/bugs/model/tests/test_bugtask.py
@@ -3150,7 +3150,8 @@ class TestTargetNameCache(TestCase):
         self.assertTrue('INFO    Updating targetname cache of bugtasks' in err)
         self.assertTrue('INFO    Calculating targets.' in err)
         self.assertTrue('INFO    Will check ' in err)
-        self.assertTrue("INFO    Updating (u'Mozilla Thunderbird',)" in err)
+        self.assertTrue(
+            ('INFO    Updating ' + repr((u'Mozilla Thunderbird',))) in err)
         self.assertTrue('INFO    Updated 1 target names.' in err)
         self.assertTrue('INFO    Finished updating targetname cache' in err)
 
diff --git a/lib/lp/bugs/scripts/checkwatches/tests/test_core.py b/lib/lp/bugs/scripts/checkwatches/tests/test_core.py
index b66b03e..afa7182 100644
--- a/lib/lp/bugs/scripts/checkwatches/tests/test_core.py
+++ b/lib/lp/bugs/scripts/checkwatches/tests/test_core.py
@@ -429,7 +429,7 @@ class ExternalBugTrackerForThreads(TestExternalBugTracker):
         self.output_file = output_file
 
     def getRemoteStatus(self, bug_id):
-        self.output_file.write("getRemoteStatus(bug_id=%r)" % bug_id)
+        self.output_file.write("getRemoteStatus(bug_id='%s')" % bug_id)
         return 'UNKNOWN'
 
     def getCurrentDBTime(self):
@@ -497,12 +497,12 @@ class TestTwistedThreadSchedulerInPlace(TestCaseWithFactory):
             ['butterscotch', 'strawberry'], sorted(output_file.output))
         # Check that getRemoteStatus() was called.
         self.assertEqual(
-            ["getRemoteStatus(bug_id=u'butterscotch-1')",
-             "getRemoteStatus(bug_id=u'butterscotch-2')",
-             "getRemoteStatus(bug_id=u'butterscotch-3')"],
+            ["getRemoteStatus(bug_id='butterscotch-1')",
+             "getRemoteStatus(bug_id='butterscotch-2')",
+             "getRemoteStatus(bug_id='butterscotch-3')"],
             output_file.output['butterscotch'])
         self.assertEqual(
-            ["getRemoteStatus(bug_id=u'strawberry-1')",
-             "getRemoteStatus(bug_id=u'strawberry-2')",
-             "getRemoteStatus(bug_id=u'strawberry-3')"],
+            ["getRemoteStatus(bug_id='strawberry-1')",
+             "getRemoteStatus(bug_id='strawberry-2')",
+             "getRemoteStatus(bug_id='strawberry-3')"],
             output_file.output['strawberry'])
diff --git a/lib/lp/buildmaster/model/buildqueue.py b/lib/lp/buildmaster/model/buildqueue.py
index cce2463..7a49cb7 100644
--- a/lib/lp/buildmaster/model/buildqueue.py
+++ b/lib/lp/buildmaster/model/buildqueue.py
@@ -324,7 +324,7 @@ class BuildQueueSet(object):
                 try:
                     return int(value_str)
                 except ValueError:
-                    logger.error('invalid %s %r', flag, value_str)
+                    logger.error("invalid %s: %s", flag, value_str)
 
         score_conditions = []
         minimum_scores = set()
diff --git a/lib/lp/buildmaster/tests/test_builder.py b/lib/lp/buildmaster/tests/test_builder.py
index 5d04e0d..33c4ca1 100644
--- a/lib/lp/buildmaster/tests/test_builder.py
+++ b/lib/lp/buildmaster/tests/test_builder.py
@@ -253,8 +253,8 @@ class TestFindBuildCandidatesGeneralCases(TestFindBuildCandidatesBase):
                     bqs[1],
                     self.bq_set.findBuildCandidates(processors[1], True, 3))
             self.assertEqual(
-                "invalid buildmaster.minimum_score u'nonsense'\n"
-                "invalid buildmaster.minimum_score u'nonsense'\n",
+                "invalid buildmaster.minimum_score: nonsense\n"
+                "invalid buildmaster.minimum_score: nonsense\n",
                 logger.output)
 
 
diff --git a/lib/lp/services/features/tests/test_webapp.py b/lib/lp/services/features/tests/test_webapp.py
index 83f5755..9ba6c63 100644
--- a/lib/lp/services/features/tests/test_webapp.py
+++ b/lib/lp/services/features/tests/test_webapp.py
@@ -123,4 +123,5 @@ class TestFeaturesIntoOops(TestCaseWithFactory):
                 self.assertTrue('features.usedScopes' in oops)
                 self.assertTrue('features.usedFlags' in oops)
                 self.assertEqual(
-                    oops['features.usedFlags'], u"{'feature_name': u'value'}")
+                    oops['features.usedFlags'],
+                    u'%r' % {'feature_name': u'value'})
diff --git a/lib/lp/soyuz/tests/test_initializedistroseriesjob.py b/lib/lp/soyuz/tests/test_initializedistroseriesjob.py
index 223d0db..e8cb577 100644
--- a/lib/lp/soyuz/tests/test_initializedistroseriesjob.py
+++ b/lib/lp/soyuz/tests/test_initializedistroseriesjob.py
@@ -102,15 +102,15 @@ class InitializeDistroSeriesJobTests(TestCaseWithFactory):
             "parent[overlay?/pockets/components]: "
             "{parent1.name}[True/Updates/main],"
             "{parent2.name}[False/Release/universe], "
-            "architectures: (u'i386', u'amd64'), "
+            "architectures: {architectures}, "
             "archindep_archtag: amd64, "
-            "packagesets: [u'{packageset1.name}', u'{packageset2.name}'], "
+            "packagesets: {packagesets}, "
             "rebuild: False>".format(
                 distroseries=distroseries,
                 parent1=parent1,
                 parent2=parent2,
-                packageset1=packageset1,
-                packageset2=packageset2))
+                architectures=('i386', 'amd64'),
+                packagesets=[packageset1.name, packageset2.name]))
         self.assertEqual(
             expected,
             repr(job)