code: def python_2_nonzero_compatible(klass):
      
      if six.PY2:
          if '__bool__' not in klass.__dict__:
              raise ValueError(
                  '@python_2_nonzero_compatible cannot be applied to {0} because '
                  'it doesn\'t define __bool__().'.format(klass.__name__))
          klass.__nonzero__ = klass.__bool__
      return klass
docs: Adds a `__nonzero__()` method to classes that define a `__bool__()` method,
      so boolean conversion works in Python 2. Has no effect in Python 3.
  
      :param klass: The class to modify. Must define `__bool__()`.
      :return: The possibly patched class.