Possibly Pythonic Tail Call Optimization (TCO/TRE)
rosuav at gmail.com
Fri Jul 17 13:05:19 CEST 2015
On Fri, Jul 17, 2015 at 8:48 PM, Antoon Pardon
<antoon.pardon at rece.vub.ac.be> wrote:
> Just wondering, are traceback records of generators available? They are
> if an exception is raised in the generator itself, but what if an exception
> is raised in the loop that is driven by a generator. They don't appear in
> the standard stack trace.
Not sure what you mean here. Something like this?
yield more stuff
for stuff in gen():
bomb with exception
The error didn't happen in the generator, so I wouldn't expect to see
it in the traceback. There's still room for the cause of an error to
not be in the traceback; imagine, for instance, a function that
populates a concrete list, and then you iterate over the list. If that
function sticks a None into the list and the subsequent processing is
expecting all strings, that's going to bomb, but then you have to
figure out where the None came from. If the traceback could include
that, it'd be great, but some things aren't possible. Doesn't mean
we're happy to sacrifice other functionality.
More information about the Python-list