# Buggy code
def __setitem__(self, index, data):
    """Sets a block with a VTK data object. To set the name simultaneously,
    pass a string name as the 2nd index.

    Example
    -------
    >>> import vtki
    >>> multi = vtki.MultiBlock()
    >>> multi[0] = vtki.PolyData()
    >>> multi[1, 'foo'] = vtki.UnstructuredGrid()
    >>> multi['bar'] = vtki.PolyData()
    >>> multi.n_blocks
    3
    """
    if isinstance(index, collections.Iterable) and not isinstance(index, str):
        i, name = index[0], index[1]
    elif isinstance(index, str):
        try:
            i = self.get_index_by_name(index)
        except KeyError:
            i = -1
        name = index
    else:
        i, name = index, None
    if data is not None and not is_vtki_obj(data):
        data = wrap(data)
    if i == -1:
        self.append(data)
        i = self.n_blocks - 1
    else:
        self.SetBlock(i, data)
    if name is None:
        name = "Block-{0:02}".format(i)
    self.set_block_name(i, name)  # Note that this calls self.Modified()


# Traceback (ReferenceError)
---------------------------------------------------------------------------
ReferenceError                            Traceback (most recent call last)
<ipython-input-5-1ae88bf5bf88> in <module>()
1 # Add values to the meshes so colors are consistent with other data
2 # try:
----> 3 proj['temp_175c'].point_arrays['Temperature'] = np.full(proj['temp_175c'].n_points, 175.)
4 proj['temp_225c'].point_arrays['Temperature'] = np.full(proj['temp_225c'].n_points, 225.)
5 #     tc = vtki.MultiBlock()

~/Documents/OpenGeoVis/Software/vtki/vtki/common.py in __setitem__(self, key, val)
883         """ overridden to assure data is contigious """
884         if self.callback_enabled:
--> 885             self.adder(val, key, deep=False)
886         dict.__setitem__(self, key, val)
887         self.modifier()

~/Documents/OpenGeoVis/Software/vtki/vtki/common.py in adder(self, scalars, name, set_active, deep)
920
921     def adder(self, scalars, name, set_active=False, deep=True):
--> 922         self.data._add_point_scalar(scalars, name, set_active=False, deep=deep)
923
924

ReferenceError: weakly-referenced object no longer exists

# Fixed code
def __setitem__(self, index, data):
    """Sets a block with a VTK data object. To set the name simultaneously,
    pass a string name as the 2nd index.

    Example
    -------
    >>> import vtki
    >>> multi = vtki.MultiBlock()
    >>> multi[0] = vtki.PolyData()
    >>> multi[1, 'foo'] = vtki.UnstructuredGrid()
    >>> multi['bar'] = vtki.PolyData()
    >>> multi.n_blocks
    3
    """
    if isinstance(index, collections.Iterable) and not isinstance(index, str):
        i, name = index[0], index[1]
    elif isinstance(index, str):
        try:
            i = self.get_index_by_name(index)
        except KeyError:
            i = -1
        name = index
    else:
        i, name = index, None
    if data is not None and not is_vtki_obj(data):
        data = wrap(data)
    if i == -1:
        self.append(data)
        i = self.n_blocks - 1
    else:
        self.SetBlock(i, data)
    if name is None:
        name = "Block-{0:02}".format(i)
    self.set_block_name(i, name)  # Note that this calls self.Modified()
    if data not in self.refs:
        self.refs.append(data)