Mercurial > public > mercurial-scm > hg
comparison mercurial/error.py @ 48889:9baec00b4ca1
error: unconditionally define __str__
We always run on Python 3 now.
Differential Revision: https://phab.mercurial-scm.org/D12292
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 21 Feb 2022 10:27:02 -0700 |
parents | 6000f5b25c9b |
children | 642e31cb55f0 |
comparison
equal
deleted
inserted
replaced
48888:07a7b57d3e33 | 48889:9baec00b4ca1 |
---|---|
66 Exception.__init__(self, message) | 66 Exception.__init__(self, message) |
67 | 67 |
68 def __bytes__(self): | 68 def __bytes__(self): |
69 return self.message | 69 return self.message |
70 | 70 |
71 if pycompat.ispy3: | 71 def __str__(self): |
72 | 72 # type: () -> str |
73 def __str__(self): | 73 # the output would be unreadable if the message was translated, |
74 # type: () -> str | 74 # but do not replace it with encoding.strfromlocal(), which |
75 # the output would be unreadable if the message was translated, | 75 # may raise another exception. |
76 # but do not replace it with encoding.strfromlocal(), which | 76 return pycompat.sysstr(self.__bytes__()) |
77 # may raise another exception. | |
78 return pycompat.sysstr(self.__bytes__()) | |
79 | 77 |
80 def format(self): | 78 def format(self): |
81 # type: () -> bytes | 79 # type: () -> bytes |
82 from .i18n import _ | 80 from .i18n import _ |
83 | 81 |