parameters: (message_descriptor, cls)
docstring: Helper for _AddMessageMethods().
docstring_summary: Helper for _AddMessageMethods().
docstring_tokens: Helper for _AddMessageMethods () .
function: def _AddClearFieldMethod(message_descriptor, cls):
    """Helper for _AddMessageMethods()."""
    def ClearField(self, field_name):
      try:
        field = message_descriptor.fields_by_name[field_name]
      except KeyError:
        raise ValueError('Protocol message has no "%s" field.' % field_name)
  
      if field in self._fields:
        # Note:  If the field is a sub-message, its listener will still point
        #   at us.  That's fine, because the worst than can happen is that it
        #   will call _Modified() and invalidate our byte size.  Big deal.
        del self._fields[field]
  
      # Always call _Modified() -- even if nothing was changed, this is
      # a mutating method, and thus calling it should cause the field to become
      # present in the parent message.
      self._Modified()
  
    cls.ClearField = ClearField
function_tokens: def _AddClearFieldMethod ( message_descriptor , cls ) : def ClearField ( self , field_name ) : try : field = message_descriptor . fields_by_name [ field_name ] except KeyError : raise ValueError ( 'Protocol message has no "%s" field.' % field_name ) if field in self . _fields : # Note:  If the field is a sub-message, its listener will still point #   at us.  That's fine, because the worst than can happen is that it #   will call _Modified() and invalidate our byte size.  Big deal. del self . _fields [ field ] # Always call _Modified() -- even if nothing was changed, this is # a mutating method, and thus calling it should cause the field to become # present in the parent message. self . _Modified ( ) cls . ClearField = ClearField