f_lasti not correct with PREDICT (is it fixable?)
Hi all, I currently have a use-case where I need to rely on `f_lasti`, but it seems that it's not really possible to rely on it as it doesn't accurately point to the actual bytecode last executed when PREDICT is used. So, I'd like to know: is it possible to change that so that the `f_lasti` is indeed properly updated (even when PREDICT) is used (to actually match what the docs say about it: https://docs.python.org/3/library/inspect.html)? As a note, my use case is doing a step into a function in a debugger. This is needed in order to know whether a given function call maps the target being step into. For instance, given something as: def method(c): return c+1 a = method a(a(a(1))) The user can choose to step into the `a` at the middle. The only conceivable way out I found to implement it reliably was by identifying that when the user enters the `method()` function the f_lasti on the parent frame is the one which would result in that function call. So, I have this working on a POC, but to have it working on all the cases I'm having to handle all existing bytecode instructions and then going to ceval.c and then identify which ones have a PREDICT and then having to do the adjustments to match the `f_lasti` accordingly when the function call is reached (which is a bit of an herculean task to support multiple versions of CPython as that's definitely an implementation detail), so, I'd really be interested in having the f_lasti work reliably. Thanks, Fabio
participants (1)
-
Fabio Zadrozny