def tracked(source, iterable):
    """Return a "tracking" generator over the items in the given stream.

    If gen.throw(exc) is called on the generator return value, then the
    generator adds information about the location of the stream to
    the exception stack trace.

    Arguments:
      source: the source of the stream (for display purposes).
      iterable: an iterable.  In particular, an iterator object is not
        required.
    """
    for i, item in enumerate(iterable, start=1):
        try:
            yield item
        except Exception as exc:
            raise type(exc)("last read item from %r (number=%d): %r" % (source, i, item))
dataset/ETHPy150Open cjerdonek/open-rcv/openrcv/streams.py/tracked/original