'Raises IOError and APEBadItemError'

def __parse_tag(self, tag, count):

    fileobj = cBytesIO(tag)
    for i in xrange(count):
        tag_data = fileobj.read(8)
        if (not tag_data):
            break
        if (len(tag_data) != 8):
            raise error
        size = cdata.uint32_le(tag_data[:4])
        flags = cdata.uint32_le(tag_data[4:8])
        kind = ((flags & 6) >> 1)
        if (kind == 3):
            raise APEBadItemError('value    type    must    be    0,    1,    or    2')
        key = value = fileobj.read(1)
        if (not key):
            raise APEBadItemError
        while ((key[(-1):] != '\x00') and value):
            value = fileobj.read(1)
            if (not value):
                raise APEBadItemError
            key += value
        if (key[(-1):] == '\x00'):
            key = key[:(-1)]
        if PY3:
            try:
                key = key.decode('ascii')
            except UnicodeError as err:
                reraise(APEBadItemError, err, sys.exc_info()[2])
        value = fileobj.read(size)
        if (len(value) != size):
            raise APEBadItemError
        value = _get_value_type(kind)._new(value)
        self[key] = value
