parameters: (message, field)
return_statement: return field.default_value
docstring: Returns a default value for a field.
  
    Args:
      message: Message instance containing this field, or a weakref proxy
        of same.
      field: FieldDescriptor object for this field.
  
    Returns: A default value for this field.  May refer back to |message|
      via a weak reference.
docstring_summary: Returns a default value for a field.
docstring_tokens: Returns a default value for a field .
function: def _DefaultValueForField(message, field):
    """Returns a default value for a field.
  
    Args:
      message: Message instance containing this field, or a weakref proxy
        of same.
      field: FieldDescriptor object for this field.
  
    Returns: A default value for this field.  May refer back to |message|
      via a weak reference.
    """
    # TODO(robinson): Only the repeated fields need a reference to 'message' (so
    # that they can set the 'has' bit on the containing Message when someone
    # append()s a value).  We could special-case this, and avoid an extra
    # function call on __init__() and Clear() for non-repeated fields.
  
    # TODO(robinson): Find a better place for the default value assertion in this
    # function.  No need to repeat them every time the client calls Clear('foo').
    # (We should probably just assert these things once and as early as possible,
    # by tightening checking in the descriptor classes.)
    if field.label == _FieldDescriptor.LABEL_REPEATED:
      if field.default_value != []:
        raise ValueError('Repeated field default value not empty list: %s' % (
            field.default_value))
      listener = _Listener(message, None)
      if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
        # We can't look at _concrete_class yet since it might not have
        # been set.  (Depends on order in which we initialize the classes).
        return containers.RepeatedCompositeFieldContainer(
            listener, field.message_type)
      else:
        return containers.RepeatedScalarFieldContainer(
            listener, type_checkers.GetTypeChecker(field.cpp_type, field.type))
  
    if field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:
      assert field.default_value is None
  
    return field.default_value
function_tokens: def _DefaultValueForField ( message , field ) : # TODO(robinson): Only the repeated fields need a reference to 'message' (so # that they can set the 'has' bit on the containing Message when someone # append()s a value).  We could special-case this, and avoid an extra # function call on __init__() and Clear() for non-repeated fields. # TODO(robinson): Find a better place for the default value assertion in this # function.  No need to repeat them every time the client calls Clear('foo'). # (We should probably just assert these things once and as early as possible, # by tightening checking in the descriptor classes.) if field . label == _FieldDescriptor . LABEL_REPEATED : if field . default_value != [ ] : raise ValueError ( 'Repeated field default value not empty list: %s' % ( field . default_value ) ) listener = _Listener ( message , None ) if field . cpp_type == _FieldDescriptor . CPPTYPE_MESSAGE : # We can't look at _concrete_class yet since it might not have # been set.  (Depends on order in which we initialize the classes). return containers . RepeatedCompositeFieldContainer ( listener , field . message_type ) else : return containers . RepeatedScalarFieldContainer ( listener , type_checkers . GetTypeChecker ( field . cpp_type , field . type ) ) if field . cpp_type == _FieldDescriptor . CPPTYPE_MESSAGE : assert field . default_value is None return field . default_value