def dict_merge(a, b):
    """
    Takes two dictionaries and merges them.

    :param a: A dictionary.
    :type a: dict
    :param b: A dictionary.
    :type b: dict
    :returns: A merged dict.
    :rtype: dict
    """
    if a and not isinstance(a, dict):
        raise TypeError('{} is not a dict'.format(a))
    if b and not isinstance(b, dict):
        raise TypeError('{} is not a dict'.format(b))
    if a is None:
        return b
    if b is not None:
        a.update(b)
        return a
    return a
