Given a Python C frame pointer, how can I look at a random stack score record? (Some specific stack entries can be found through locals(); I'm talking about other stack entries.)
I asked a wider question like this recently:
getting exec p python argument string or accessing evaluation stack
but here I want to focus on being able to read CPython stack entries at runtime.
I will take a solution that works on CPython 2.7 or on any Python later than Python 3.3. However, if you have things that work outside of this, share it and, if there is no better solution, I agree with that.
I would prefer not to modify the Python C code. In Ruby, I really did this to get what I want. From experience, I can say that this is probably not the way we want to work. But then again, if there is no better solution, I will take it. (My understanding regarding SO points is that I lose him in generosity anyway. Therefore, I am happy to go look at the person who showed the best spirit and willingness to look at it, assuming it works.)
update: User Comment2357112 TL; DR; In principle, this is difficult to do. (However, if you think you have a desire to try, be sure to do it.)
So let me narrow down the scope of this simpler problem, which, in my opinion, is doable:
python, inspect.currentframe(), . C f_valuestack. Python, / Python .
2, , ( ) . , , , . ", , ", " " , - , , , 190 . . ...
- , , .
.