def _dict(obj):
    """Work with obj.__dict__ or obj if it doesn't have one (it should be one).
    This lets us pass in regular objects or their dicts (like f_locals).
    """
    return getattr(obj, '__dict__', obj)
