On 10:55 pm, collinwin...@google.com wrote:
That people are directly munging CPython
bytecode means that CPython should provide a better, more abstract way
to do the same thing that's more resistant to these kinds of changes.
Yes, definitely! Requesting a supported way to do the kind of
introspection that you mentioned earlier (I think it's a little simpler
than you recollect) has been on my todo list for a while. The hold-up
is just figuring out exactly what kind of introspection API would make
sense.
It might be helpful to hear more about how the wordcode implementation
differs from the bytecode implementation. It's challenging to abstract
from a single data point. :)
For what it's worth, I think this is the code in Twisted that Collin was
originally referring to:
# it is only really originating from
# throwExceptionIntoGenerator if the bottom of the traceback
# is a yield.
# Pyrex and Cython extensions create traceback frames
# with no co_code, but they can't yield so we know it's okay to
just
# return here.
if ((not lastFrame.f_code.co_code) or
lastFrame.f_code.co_code[lastTb.tb_lasti] !=
cls._yieldOpcode):
return
And it's meant to be used in code like this:
def foo():
try:
yield
except:
# raise a new exception
def bar():
g = foo()
g.next()
try:
g.throw(...)
except:
# Code above is invoked to determine if the exception raised
# was the one that was thrown into the generator or a different
# one.
Jean-Paul
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com