def unpack_pairs(data):
        end = len(data)
        pos = 0
        while pos < end:
            try:
                name_len, pos = unpack_len(data, pos)
                value_len, pos = unpack_len(data, pos)
            except (IndexError, struct.error):
                raise ValueError('Buffer is too short')

            if end - pos < name_len + value_len:
                raise ValueError('Buffer is {0} bytes short'.format(
                    name_len + value_len - (end - pos)))
            name = data[pos:pos + name_len]
            pos += name_len
            value = data[pos:pos + value_len]
            pos += value_len
            yield name, value
dataset/ETHPy150Open momyc/gevent-fastcgi/gevent_fastcgi/utils.py/unpack_pairs/original