def failure_to_context(report, context):
    """If a twisted_failure key is present, use it to set context['exc_info'].

    This permits using regular python hooks with a twisted failure.
    """
    failure = context.get('twisted_failure')
    if not failure:
        return
    exc_info = failure.type, failure.value, failure.getTraceback()
    context['exc_info'] = exc_info
    del exc_info
