changeset 40949:f732889abe0e

error: implement __str__ on RevlogError to fix some output defects on Py3 We open-code encoding.unimethod here to avoid cycles, and do a local import of encoding when someone str()s a RevlogError. It's not my favorite solution, but it gets the job done. Differential Revision: https://phab.mercurial-scm.org/D5426
author Augie Fackler <augie@google.com>
date Fri, 14 Dec 2018 12:01:47 -0500
parents a314eafd7c8d
children 52fbf8a9907c
files mercurial/error.py
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/error.py	Fri Dec 14 12:00:38 2018 -0500
+++ b/mercurial/error.py	Fri Dec 14 12:01:47 2018 -0500
@@ -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