When you use a context manager, you can collect code block inside it based on line number in sys._getframe().f_back.f_lineno and linecache.getlines(file). For example
with some_context():
# At this point line number is N
do_something()
# exit line number is M
Before 3.10, M = N +2 holds but in 3.10 it is M = N. Is it a bug or new design?
When you use a context manager, you can collect code block inside it based on line number in
sys._getframe().f_back.f_lineno
andlinecache.getlines(file)
. For exampleBefore 3.10,
M = N +2
holds but in 3.10 it isM = N
. Is it a bug or new design?