comparison mercurial/error.py @ 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 b63dee7bd0d9
children 2393c4044214
comparison
equal deleted inserted replaced
40948:a314eafd7c8d 40949:f732889abe0e
41 """ 41 """
42 __bytes__ = _tobytes 42 __bytes__ = _tobytes
43 43
44 class RevlogError(StorageError): 44 class RevlogError(StorageError):
45 __bytes__ = _tobytes 45 __bytes__ = _tobytes
46
47 def __str__(self):
48 # avoid cycle, and directly implement unimethod for this
49 # __str__ to allow delaying the import of encoding until
50 # someone actually wants the __str__ of a RevlogError (which
51 # should be very rare).
52 from . import encoding
53 return encoding.unifromlocal(_tobytes(self))
46 54
47 class FilteredIndexError(IndexError): 55 class FilteredIndexError(IndexError):
48 __bytes__ = _tobytes 56 __bytes__ = _tobytes
49 57
50 class LookupError(RevlogError, KeyError): 58 class LookupError(RevlogError, KeyError):