Message from exception raised in generator disappears

Thomas Bellman bellman at lysator.liu.se
Sun Oct 17 10:26:28 EDT 2004


Jeff Epler <jepler at unpythonic.net> wrote:

> >>> def gx():
> ...     yield 1
> ...     raise RuntimeError
> ... 
> >>> list(gx())
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<stdin>", line 3, in gx
> RuntimeError

> Exceptions in generators work for me.  Maybe there's another problem
> with your code.

However:

    >>> def gx():
    ...     yield "1"
    ...     raise TypeError("SPAM SPAM SPAM!")
    ...
    >>> " ".join(gx())
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    TypeError: sequence expected, generator found

Bug 905389 at the SourceForge bugtracker.


-- 
Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"God is real, but Jesus is an integer."      !  bellman @ lysator.liu.se
                                             !  Make Love -- Nicht Wahr!




More information about the Python-list mailing list