Dennis Sweeney added the comment:
With the advent of zero-cost exception handling in Python 3.10, there is no
block stack, neither for exceptions nor for loops. These were always regarded
as an implementation detail of the compiler. If you have any new ideas for a
feature like this, I would
Dennis Sweeney added the comment:
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:
https://docs.python.org/3/library/dis.html#opcode-SETUP_FINALLY
Meanwhile, loops and conditionals and the like
New submission from Gregoire Chalony :
The inspect module doesn't currently expose any way to access the block stack
at runtime.
Would that be possible?
Aked on StackOverflow here:
https://stackoverflow.com/questions/63187845/cpython-access-loop-depth-level-block-stack.
--
messages: