%debug magic does not work repeatably for untitled files
See original GitHub issueWhat steps reproduce the problem?
-
Create a simple file with a single cell with like this:
#%% define foo def foo(bar): x = ['a'] for i in range(100): x.append(i + 3) return x
-
Execute the file using the green arrow:
runfile('.../test.py', wdir='...')
-
Place a breakpoint in line 4:
-
Run a
%debug
magic onfoo
with any argument:Enters debugging normally:
-
Quit debugging (or step through) and try again
Only “s” appears to work, and pressing “c” ignores the breakpoint entirely:
Expected Behavior
I expect %debug
to work twice, especially when I don’t modify the file.
Attempted solutions:
- Rerun the file: Does not work
- Modify the file, save it, then rerurn and attempt to debug. Output shows that the modification propagated to the
foo
in the console: Does not work. - Clear all variables. Does not work.
- Restart kernel (or IDE). That works as expected every time. But doesn’t seem like that’s a very good solution.
Comment
The reason that I mention cells in the example is that ideally, I would like to reload my code by running the cell rather than the entire file. The files I have at the moment are sort of like notebooks that I am using the cell functionality to run. I would love not to have to reload the entire file (mush less the kernel), every time I made a change just to the function I’m trying to debug.
Versions
- Spyder version: 4.1.5
- Python version: 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)]
- Qt version: 5.9.7
- PyQt version: 5.9.2
- Operating System name/version: Windows 10
Dependencies
# Mandatory:
atomicwrites >=1.2.0 : 1.4.0 (OK)
chardet >=2.0.0 : 4.0.0 (OK)
cloudpickle >=0.5.0 : 1.6.0 (OK)
diff_match_patch >=20181111 : 20200713 (OK)
intervaltree : None (OK)
IPython >=4.0 : 7.22.0 (OK)
jedi =0.17.1 : 0.17.1 (OK)
nbconvert >=4.0 : 6.0.7 (OK)
numpydoc >=0.6.0 : 1.1.0 (OK)
paramiko >=2.4.0 : 2.7.2 (OK)
parso =0.7.0 : 0.7.0 (OK)
pexpect >=4.4.0 : 4.8.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=5.3 : 5.8.0 (OK)
pygments >=2.0 : 2.8.1 (OK)
pylint >=1.0 : 2.7.4 (OK)
pyls >=0.34.0;<1.0.0 : 0.34.1 (OK)
qdarkstyle >=2.8 : 3.0.2 (OK)
qtawesome >=0.5.7 : 1.0.2 (OK)
qtconsole >=4.6.0 : 5.0.3 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.9.7 (OK)
sphinx >=0.6.6 : 3.1.2 (OK)
spyder_kernels >=1.9.4;<1.10.0 : 1.9.4 (OK)
watchdog : None (OK)
zmq >=17 : 20.0.0 (OK)
# Optional:
cython >=0.21 : 0.29.23 (OK)
matplotlib >=2.0.0 : 3.3.4 (OK)
numpy >=1.7 : 1.20.1 (OK)
pandas >=0.13.1 : 1.2.4 (OK)
scipy >=0.17.0 : 1.6.2 (OK)
sympy >=0.7.3 : 1.8 (OK)
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
@impact27 thank you for the fix. I look forward to using it
@impact27 was the one who really fixed this.