TypeError + generator + str.join(): Bug or user error?

Paul Du Bois paul.dubois at gmail.com
Mon Apr 10 22:54:26 EDT 2006


Using win32 python 2.4.1, I have a minimal test program:

def generate():
    raise TypeError('blah')
    yield ""

print "\n".join((generate()))

Executing the program gives:

Traceback (most recent call last):
  File "<stdin>", line 5, in ?
TypeError: sequence expected, generator found

replacing TypeError with Exception gives what I would have expected: a
traceback starting from the raise statement. I'm not relying on one
behavior or the other, but I had a TypeError in a generator, and the
funny exception slowed me down finding it.

p




More information about the Python-list mailing list