import functools


def update_wrapper(wrapper, wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
                   updated=functools.WRAPPER_UPDATES):
    """ Update a wrapper function to look like the wrapped function.

        Modified version to support partial and other non-__dict__ objects.
        See functools.update_wrapper for full documentation.
    """
    for attr in assigned:
        try:
            setattr(wrapper, attr, getattr(wrapped, attr))
        except AttributeError:
            pass
    for attr in updated:
        try:
            getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
        except AttributeError:
            pass
    # Return the wrapper so this can be used as a decorator via partial()
    return wrapper