Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/error.py @ 45918:64faa55716f4
tests: make test-worker.t pass on py2
I broke the py2 version in https://phab.mercurial-scm.org/D9287
because the `WorkerError.__bytes__()` (or `.__str__()`?) output was
different in py2 compared to py3. Part of the problem was that I
didn't propagate the status code that was passed in to the superclass
so it could get printed. This patch fixes that. I don't know how it
worked on py3 before this patch...
I also added the usual `__bytes__ = _tobytes` override for good
measure. It doesn't seem to be needed for tests to pass, though.
Differential Revision: https://phab.mercurial-scm.org/D9377
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 23 Nov 2020 11:56:10 -0800 |
parents | 9dc1351d0b5f |
children | 8f50dc096cf4 |
comparison
equal
deleted
inserted
replaced
45917:6da22a068281 | 45918:64faa55716f4 |
---|---|
135 class WorkerError(Exception): | 135 class WorkerError(Exception): |
136 """Exception raised when a worker process dies.""" | 136 """Exception raised when a worker process dies.""" |
137 | 137 |
138 def __init__(self, status_code): | 138 def __init__(self, status_code): |
139 self.status_code = status_code | 139 self.status_code = status_code |
140 # Pass status code to superclass just so it becomes part of __bytes__ | |
141 super(WorkerError, self).__init__(status_code) | |
142 | |
143 __bytes__ = _tobytes | |
140 | 144 |
141 | 145 |
142 class InterventionRequired(Hint, Exception): | 146 class InterventionRequired(Hint, Exception): |
143 """Exception raised when a command requires human intervention.""" | 147 """Exception raised when a command requires human intervention.""" |
144 | 148 |