code: def _AddPropertiesForRepeatedField(field, cls):
    
    proto_field_name = field.name
    property_name = _PropertyName(proto_field_name)
  
    def getter(self):
      field_value = self._fields.get(field)
      if field_value is None:
        # Construct a new object to represent this field.
        field_value = field._default_constructor(self)
  
        # Atomically check if another thread has preempted us and, if not, swap
        # in the new object we just created.  If someone has preempted us, we
        # take that object and discard ours.
        # WARNING:  We are relying on setdefault() being atomic.  This is true
        #   in CPython but we haven't investigated others.  This warning appears
        #   in several other locations in this file.
        field_value = self._fields.setdefault(field, field_value)
      return field_value
    getter.__module__ = None
    getter.__doc__ = 'Getter for %s.' % proto_field_name
  
    # We define a setter just so we can throw an exception with a more
    # helpful error message.
    def setter(self, new_value):
      raise AttributeError('Assignment not allowed to repeated field '
                           '"%s" in protocol message object.' % proto_field_name)
  
    doc = 'Magic attribute generated for "%s" proto field.' % proto_field_name
    setattr(cls, property_name, property(getter, setter, doc=doc))
docs: Adds a public property for a "repeated" protocol message field.  Clients
    can use this property to get the value of the field, which will be either a
    _RepeatedScalarFieldContainer or _RepeatedCompositeFieldContainer (see
    below).
  
    Note that when clients add values to these containers, we perform
    type-checking in the case of repeated scalar fields, and we also set any
    necessary "has" bits as a side-effect.
  
    Args:
      field: A FieldDescriptor for this field.
      cls: The class we're constructing.