def MessageSetItemDecoder(extensions_by_number):
type_id_tag_bytes = encoder.TagBytes(<NUM_LIT:2>, wire_format.WIRETYPE_VARINT)<EOL>message_tag_bytes = encoder.TagBytes(<NUM_LIT:3>, wire_format.WIRETYPE_LENGTH_DELIMITED)<EOL>item_end_tag_bytes = encoder.TagBytes(<NUM_LIT:1>, wire_format.WIRETYPE_END_GROUP)<EOL>local_ReadTag = ReadTag<EOL>local_DecodeVarint = _DecodeVarint<EOL>local_SkipField = SkipField<EOL>def DecodeItem(buffer, pos, end, message, field_dict):<EOL><INDENT>message_set_item_start = pos<EOL>type_id = -<NUM_LIT:1><EOL>message_start = -<NUM_LIT:1><EOL>message_end = -<NUM_LIT:1><EOL>while <NUM_LIT:1>:<EOL><INDENT>(tag_bytes, pos) = local_ReadTag(buffer, pos)<EOL>if tag_bytes == type_id_tag_bytes:<EOL><INDENT>(type_id, pos) = local_DecodeVarint(buffer, pos)<EOL><DEDENT>elif tag_bytes == message_tag_bytes:<EOL><INDENT>(size, message_start) = local_DecodeVarint(buffer, pos)<EOL>pos = message_end = message_start + size<EOL><DEDENT>elif tag_bytes == item_end_tag_bytes:<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>pos = SkipField(buffer, pos, end, tag_bytes)<EOL>if pos == -<NUM_LIT:1>:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>if pos > end:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>if type_id == -<NUM_LIT:1>:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>if message_start == -<NUM_LIT:1>:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>extension = extensions_by_number.get(type_id)<EOL>if extension is not None:<EOL><INDENT>value = field_dict.get(extension)<EOL>if value is None:<EOL><INDENT>value = field_dict.setdefault(<EOL>extension, extension.message_type._concrete_class())<EOL><DEDENT>if value._InternalParse(buffer, message_start,message_end) != message_end:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not message._unknown_fields:<EOL><INDENT>message._unknown_fields = []<EOL><DEDENT>message._unknown_fields.append((MESSAGE_SET_ITEM_TAG,<EOL>buffer[message_set_item_start:pos]))<EOL><DEDENT>return pos<EOL><DEDENT>return DecodeItem<EOL>
Returns a decoder for a MessageSet item.

    The parameter is the _extensions_by_number map for the message class.

    The message set message looks like this:
      message MessageSet {
        repeated group Item = 1 {
          required int32 type_id = 2;
          required string message = 3;
        }
      }