Mercurial > public > mercurial-scm > hg
comparison mercurial/error.py @ 39579:921aeb9ac508
error: ensure ProgrammingError message is always a str
Since this error is internal-only and a runtime error, let's give it a
treatment that makes it behave identically when repr()d on both Python
2 and Python 3.
Differential Revision: https://phab.mercurial-scm.org/D4545
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 12 Sep 2018 11:37:34 -0400 |
parents | 07b58266bce3 |
children | 409c42d6a570 |
comparison
equal
deleted
inserted
replaced
39578:b781709799f6 | 39579:921aeb9ac508 |
---|---|
213 """An exception raised during unbundling that indicate a push race""" | 213 """An exception raised during unbundling that indicate a push race""" |
214 __bytes__ = _tobytes | 214 __bytes__ = _tobytes |
215 | 215 |
216 class ProgrammingError(Hint, RuntimeError): | 216 class ProgrammingError(Hint, RuntimeError): |
217 """Raised if a mercurial (core or extension) developer made a mistake""" | 217 """Raised if a mercurial (core or extension) developer made a mistake""" |
218 | |
219 def __init__(self, msg, *args, **kwargs): | |
220 if not isinstance(msg, str): | |
221 # This means we're on Python 3, because we got a | |
222 # bytes. Turn the message back into a string since this is | |
223 # an internal-only error that won't be printed except in a | |
224 # stack traces. | |
225 msg = msg.decode('utf8') | |
226 super(ProgrammingError, self).__init__(msg, *args, **kwargs) | |
227 | |
218 __bytes__ = _tobytes | 228 __bytes__ = _tobytes |
219 | 229 |
220 class WdirUnsupported(Exception): | 230 class WdirUnsupported(Exception): |
221 """An exception which is raised when 'wdir()' is not supported""" | 231 """An exception which is raised when 'wdir()' is not supported""" |
222 __bytes__ = _tobytes | 232 __bytes__ = _tobytes |