Closed impact27 closed 6 months ago
To reproduce on unix:
create a file containing
def fun(a):
a = a + 1
print(a)
and save it as a.py
. Place a breakpoint on the second line
In a terminal:
mkdir folder
ln a.py folder/a.py
change the working directory to folder
then execute
from a import fun
%debug fun(0)
The debugger will not see any breakpoint in folder/a.py
but will see breakpoints in a.py
, even though it is the same file (in this example through a hard link)
A file can have several associated paths. For example, on windows, network shares can present "virtual drive letters" so there are several way of accessing them. To address this issue,
os.path.samefile
usesos.stat()
, see:https://docs.python.org/3/library/os.path.html#os.path.samefile
The problem is that the debugger doesn't rely on
os.stat
and instead only callsos.path.abspath
andos.path.normpath
. This means that if a breakpoint is set in Spyder on a file loaded with some path, and then in the console the file is loaded with some other path, the breakpoints will not apply.