def _AddSerializePartialToStringMethod(message_descriptor, cls):
def SerializePartialToString(self):<EOL><INDENT>out = BytesIO()<EOL>self._InternalSerialize(out.write)<EOL>return out.getvalue()<EOL><DEDENT>cls.SerializePartialToString = SerializePartialToString<EOL>def InternalSerialize(self, write_bytes):<EOL><INDENT>for field_descriptor, field_value in self.ListFields():<EOL><INDENT>field_descriptor._encoder(write_bytes, field_value)<EOL><DEDENT>for tag_bytes, value_bytes in self._unknown_fields:<EOL><INDENT>write_bytes(tag_bytes)<EOL>write_bytes(value_bytes)<EOL><DEDENT><DEDENT>cls._InternalSerialize = InternalSerialize<EOL>
Helper for _AddMessageMethods().