def _make_sentinel(name, reprstring, docstring, truthy=True):
    """Return a new object instance to use as a sentinel to represent
    an entity that cannot be used directly because of some logical
    reason or implementation detail.

    * Query uses a sentinel for the result data when optimizing
      queries because the result does not exist until the query
      is actually executed.
    * _get_error() uses a sentinel to build an appropriate error
      when objects normally required for processing are not found.
    * DataError uses a sentinel to compare float('nan') objects
      because they are not considered to be equal when directly
      compared.
    """
    cls_dict = {'__repr__': lambda self: reprstring, '__doc__': docstring}
    if not truthy:
        cls_dict['__bool__'] = lambda self: False
        cls_dict['__nonzero__'] = lambda self: False
    return type(name, (object,), cls_dict)()
