# Buggy code
def _call_task_errbacks(self, request, exc, traceback):
    old_signature = []
    for errback in request.errbacks:
        errback = self.app.signature(errback)
        if arity_greater(errback.type.__header__, 1):
            errback(request, exc, traceback)
        else:
            old_signature.append(errback)
    if old_signature:
        # Previously errback was called as a task so we still
        # need to do so if the errback only takes a single task_id arg.
        task_id = request.id
        root_id = request.root_id or task_id
        group(old_signature, app=self.app).apply_async(
            (task_id,), parent_id=task_id, root_id=root_id
        )


# Traceback (TypeError)
[2016-12-28 07:36:12,692: INFO/MainProcess] Received task: raise_exception[b10b8451-3f4d-4cf0-b4b0-f964105cf849]
[2016-12-28 07:36:12,847: INFO/PoolWorker-5] /usr/local/lib/python2.7/dist-packages/celery/app/trace.py:542: RuntimeWarning: Exception raised outside body: TypeError('<functools.partial object at 0x7f74848dffc8> is not a Python function',):
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 381, in trace_task
I, R, state, retval = on_error(task_request, exc, uuid)
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 323, in on_error
task, request, eager=eager, call_errbacks=call_errbacks,
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 157, in handle_error_state
call_errbacks=call_errbacks)
File "/usr/local/lib/python2.7/dist-packages/celery/app/trace.py", line 202, in handle_failure
call_errbacks=call_errbacks,
File "/usr/local/lib/python2.7/dist-packages/celery/backends/base.py", line 168, in mark_as_failure
self._call_task_errbacks(request, exc, traceback)
File "/usr/local/lib/python2.7/dist-packages/celery/backends/base.py", line 174, in _call_task_errbacks
if arity_greater(errback.type.__header__, 1):
File "/usr/local/lib/python2.7/dist-packages/celery/utils/functional.py", line 292, in arity_greater
argspec = getfullargspec(fun)
File "/usr/local/lib/python2.7/dist-packages/vine/five.py", line 350, in getfullargspec
s = _getargspec(fun)
File "/usr/lib/python2.7/inspect.py", line 816, in getargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <functools.partial object at 0x7f74848dffc8> is not a Python function

exc, exc_info.traceback)))
[2016-12-28 07:36:12,922: ERROR/MainProcess] Pool callback raised exception: TypeError('<functools.partial object at 0x7f74848dffc8> is not a Python function',)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/billiard/pool.py", line 1748, in safe_apply_callback
fun(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery/worker/request.py", line 366, in on_failure
self.id, exc, request=self, store_result=self.store_errors,
File "/usr/local/lib/python2.7/dist-packages/celery/backends/base.py", line 168, in mark_as_failure
self._call_task_errbacks(request, exc, traceback)
File "/usr/local/lib/python2.7/dist-packages/celery/backends/base.py", line 174, in _call_task_errbacks
if arity_greater(errback.type.__header__, 1):
File "/usr/local/lib/python2.7/dist-packages/celery/utils/functional.py", line 292, in arity_greater
argspec = getfullargspec(fun)
File "/usr/local/lib/python2.7/dist-packages/vine/five.py", line 350, in getfullargspec
s = _getargspec(fun)
File "/usr/lib/python2.7/inspect.py", line 816, in getargspec
raise TypeError('{!r} is not a Python function'.format(func))
TypeError: <functools.partial object at 0x7f74848dffc8> is not a Python function

# Fixed code
def _call_task_errbacks(self, request, exc, traceback):
    old_signature = []
    for errback in request.errbacks:
        errback = self.app.signature(errback)
        if (
            # workaround to support tasks with bind=True executed as
            # link errors. Otherwise retries can't be used
            not isinstance(errback.type.__header__, partial)
            and arity_greater(errback.type.__header__, 1)
        ):
            errback(request, exc, traceback)
        else:
            old_signature.append(errback)
    if old_signature:
        # Previously errback was called as a task so we still
        # need to do so if the errback only takes a single task_id arg.
        task_id = request.id
        root_id = request.root_id or task_id
        group(old_signature, app=self.app).apply_async(
            (task_id,), parent_id=task_id, root_id=root_id
        )