← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Commit message:
Make LaunchpadFault.__repr__ more informative

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

This brings us into line with Python >= 3.5's behaviour, even if we're running on an earlier version.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-LaunchpadFault-repr into launchpad:master.
diff --git a/lib/lp/codehosting/vfs/tests/test_branchfs.py b/lib/lp/codehosting/vfs/tests/test_branchfs.py
index d159450..b0ed94c 100644
--- a/lib/lp/codehosting/vfs/tests/test_branchfs.py
+++ b/lib/lp/codehosting/vfs/tests/test_branchfs.py
@@ -1069,7 +1069,7 @@ class TestBranchChangedErrorHandling(TestCaseWithTransport, TestCase):
         # The text printed to stderr should be like this:
         # (we need the prefix text later for extracting the oopsid)
         expected_fault_text_prefix = """
-        <Fault 380: 'An unexpected error has occurred while updating a
+        <OopsOccurred 380: 'An unexpected error has occurred while updating a
         Launchpad branch. Please report a Launchpad bug and quote:"""
         expected_fault_text = expected_fault_text_prefix + " OOPS-.*'>"
 
diff --git a/lib/lp/services/xmlrpc.py b/lib/lp/services/xmlrpc.py
index 9eff891..12b01ea 100644
--- a/lib/lp/services/xmlrpc.py
+++ b/lib/lp/services/xmlrpc.py
@@ -36,6 +36,14 @@ class LaunchpadFault(xmlrpc_client.Fault):
         msg = self.msg_template % kw
         xmlrpc_client.Fault.__init__(self, self.error_code, msg)
 
+    def __repr__(self):
+        # Use the more informative version from Python >= 3.5, even if we're
+        # running on an earlier version.
+        # XXX cjwatson 2020-10-22: Remove this once we're using Python >=
+        # 3.5 everywhere.
+        return "<%s %s: %r>" % (
+            self.__class__.__name__, self.faultCode, self.faultString)
+
     def __eq__(self, other):
         if not isinstance(other, LaunchpadFault):
             return False