I have following two python files in the same directory:
main.py
from module import f1
f1()
module.py
import traceback
def f1():
print('f1')
print(traceback.extract_stack()[-1].filename)
print(traceback.extract_stack()[-2].filename)
f2()
def f2():
print('f2')
print(traceback.extract_stack()[-1].filename)
print(traceback.extract_stack()[-2].filename)
I started VSCode in the directory and set conditional breakpoints with following expression :
traceback.extract_stack()[-2].filename != traceback.extract_stack()[-1].filename
on the first print
statement in f1
and f2
.
The running of main.py printed out :
f1
c:\Users\...\tmp\pythonTest-breakpoint\module.py
c:\Users\...\tmp\pythonTest-breakpoint\main.py
f2
c:\Users\...\tmp\pythonTest-breakpoint\module.py
c:\Users\...\tmp\pythonTest-breakpoint\module.py
Both breakpoints are triggerred.
Why the breakpoint in f2 get triggerred whereas the condition is not met ?