Title: access block stack
Type: enhancement Stage:
Components: Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, gchalony
Priority: normal Keywords:

Created on 2020-09-24 08:23 by gchalony, last changed 2020-09-25 02:48 by Dennis Sweeney.

Messages (2)
msg377442 - (view) Author: Gregoire Chalony (gchalony) Date: 2020-09-24 08:23
The inspect module doesn't currently expose any way to access the block stack at runtime.
Would that be possible?

Aked on StackOverflow here:
msg377475 - (view) Author: Dennis Sweeney (Dennis Sweeney) * Date: 2020-09-25 02:48
I believe the block stack is only for catching exceptions. Loops do not interact with the block stack. Only SETUP_FINALLY adds to the block stack:

Meanwhile, loops and conditionals and the like are compiled into goto-like jumps.

There may be some existing solution, but I'm not sure what. Maybe look at the traceback or ast modules.
Date User Action Args
2020-09-25 02:48:48Dennis Sweeneysetnosy: + Dennis Sweeney
messages: + msg377475
2020-09-24 08:23:10gchalonycreate