def PyException_GetTraceback(space, w_exc):
    """Return the traceback associated with the exception as a new reference, as
    accessible from Python through __traceback__.  If there is no
    traceback associated, this returns NULL."""
    w_tb = space.getattr(w_exc, space.wrap('__traceback__'))
    if space.is_none(w_tb):
        return None
    return w_tb