def _stacktrace_end(stacktrace, size):
    """ Gets the last `size` bytes of the stacktrace """
    stacktrace_length = len(stacktrace)
    if stacktrace_length <= size:
        return stacktrace
    return stacktrace[:-(stacktrace_length - size)]
