Patchwork [2,of,2] py3: unimplement RevlogError.__str__()

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 16, 2018, 9:02 a.m.
Message ID <12253a8199a0158bb2aa.1544950936@mimosa>
Download mbox | patch
Permalink /patch/37211/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 16, 2018, 9:02 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1544950508 -32400
#      Sun Dec 16 17:55:08 2018 +0900
# Node ID 12253a8199a0158bb2aa53ef08e8b10ec330e24c
# Parent  8c8fcb385c46890e1dc5d00ce3ced360974cecef
py3: unimplement RevlogError.__str__()

On Python 2, str(exc) would crash if __str__() returned a unicode containing
non-ASCII characters.

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -44,14 +44,6 @@  class StorageError(Hint, Exception):
 class RevlogError(StorageError):
     __bytes__ = _tobytes
 
-    def __str__(self):
-        # avoid cycle, and directly implement unimethod for this
-        # __str__ to allow delaying the import of encoding until
-        # someone actually wants the __str__ of a RevlogError (which
-        # should be very rare).
-        from . import encoding
-        return encoding.unifromlocal(_tobytes(self))
-
 class FilteredIndexError(IndexError):
     __bytes__ = _tobytes