Patchwork D5426: error: implement __str__ on RevlogError to fix some output defects on Py3

login
register
mail settings
Submitter phabricator
Date Dec. 14, 2018, 5:30 p.m.
Message ID <76653482cd90df769a7cd8f7dbae3dbe@localhost.localdomain>
Download mbox | patch
Permalink /patch/37153/
State Not Applicable
Headers show

Comments

phabricator - Dec. 14, 2018, 5:30 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG248c53e169a0: error: implement __str__ on RevlogError to fix some output defects on Py3 (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5426?vs=12851&id=12854

REVISION DETAIL
  https://phab.mercurial-scm.org/D5426

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -44,6 +44,14 @@ 
 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