comparison mercurial/error.py @ 40972:2393c4044214

py3: unimplement RevlogError.__str__() On Python 2, str(exc) would crash if __str__() returned a unicode containing non-ASCII characters.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 16 Dec 2018 17:55:08 +0900
parents f732889abe0e
children 294afb982a88
comparison
equal deleted inserted replaced
40971:8c8fcb385c46 40972:2393c4044214
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))
54 46
55 class FilteredIndexError(IndexError): 47 class FilteredIndexError(IndexError):
56 __bytes__ = _tobytes 48 __bytes__ = _tobytes
57 49
58 class LookupError(RevlogError, KeyError): 50 class LookupError(RevlogError, KeyError):