Skip to content

Commit

Permalink
Fix bug in TraceInfo._log_error() where the real exception obj was hi…
Browse files Browse the repository at this point in the history
…ding behind 'ExceptionWithTraceback' (#7930)

* Fix bug in TraceInfo._log_error() where the real exception obj was hiding behind 'ExceptionWithTraceback'

* Commit 629bc63 introduced a bug in test_execute_jail_failure.
This reverts the bug in the test, now that the real bug is fixed in the TraceInfo._log_error() method
  • Loading branch information
Nusnus committed Nov 29, 2022
1 parent 2960b89 commit cd3486d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion celery/app/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from collections import namedtuple
from warnings import warn

from billiard.einfo import ExceptionInfo
from billiard.einfo import ExceptionInfo, ExceptionWithTraceback
from kombu.exceptions import EncodeError
from kombu.serialization import loads as loads_message
from kombu.serialization import prepare_accept_content
Expand Down Expand Up @@ -238,6 +238,8 @@ def handle_failure(self, task, req, store_errors=True, call_errbacks=True):

def _log_error(self, task, req, einfo):
eobj = einfo.exception = get_pickled_exception(einfo.exception)
if isinstance(eobj, ExceptionWithTraceback):
eobj = einfo.exception = eobj.exc
exception, traceback, exc_info, sargs, skwargs = (
safe_repr(eobj),
safe_str(einfo.traceback),
Expand Down
2 changes: 1 addition & 1 deletion t/unit/worker/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_execute_jail_failure(self):
self.app, uuid(), self.mytask_raising.name, {}, [4], {},
)
assert isinstance(ret, ExceptionInfo)
assert ret.exception.exc.args == (4,)
assert ret.exception.args == (4,)

def test_execute_task_ignore_result(self):
@self.app.task(shared=False, ignore_result=True)
Expand Down

0 comments on commit cd3486d

Please sign in to comment.