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

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 5, 2019, 12:49 p.m.
Message ID <ea5b708e3f51afe6591d.1572958178@mimosa>
Download mbox | patch
Permalink /patch/42749/
State New
Headers show

Comments

Yuya Nishihara - Nov. 5, 2019, 12:49 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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):