[PATCH 1 of 2 STABLE] py3: do not reimplement Abort.__str__() on Python 2

Yuya Nishihara yuya at tcha.org
Tue Nov 5 12:49:38 UTC 2019


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1572956980 -32400
#      Tue Nov 05 21:29:40 2019 +0900
# Branch stable
# Node ID ea5b708e3f51afe6591d7e595a7bcdd5e909cfc1
# Parent  a77338d2bdabb7aa81bb275b3794de7707843545
py3: do not reimplement Abort.__str__() on Python 2

It isn't necessary on Python 2, and the default implementation should be
better than our BaseException_str() clone.

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -111,8 +111,10 @@ class Abort(Hint, Exception):
 
     __bytes__ = _tobytes
 
-    def __str__(self):
-        return pycompat.sysstr(self.__bytes__())
+    if pycompat.ispy3:
+
+        def __str__(self):
+            return pycompat.sysstr(self.__bytes__())
 
 
 class HookLoadError(Abort):


More information about the Mercurial-devel mailing list