question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

%debug magic does not work repeatably for untitled files

See original GitHub issue

What steps reproduce the problem?

  1. 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
    
  2. Execute the file using the green arrow:

    runfile('.../test.py', wdir='...')
    
  3. Place a breakpoint in line 4: image

  4. Run a %debug magic on foo with any argument: image

    Enters debugging normally: image

  5. Quit debugging (or step through) and try again

    image image

    Only “s” appears to work, and pressing “c” ignores the breakpoint entirely:

    image

Expected Behavior

I expect %debug to work twice, especially when I don’t modify the file.

Attempted solutions:

  1. Rerun the file: image Does not work
  2. Modify the file, save it, then rerurn and attempt to debug. Output shows that the modification propagated to the foo in the console: image image Does not work.
  3. Clear all variables. Does not work.
  4. 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:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
madphysicistcommented, Jan 27, 2022

@impact27 thank you for the fix. I look forward to using it

0reactions
ccordoba12commented, Jan 25, 2022

@impact27 was the one who really fixed this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging untitled file in IW shows unbound breakpoints
Breakpoints are not considered verified if the ITextFileService says the file that they're in is dirty.
Read more >
debug magic function in ipython console - Stack Overflow
In that file I have a bunch of functions and I would like to debug one of them, called foo.bar by setting a...
Read more >
Magic number (programming) - Wikipedia
In computer programming, a magic number is any of the following: A unique value with unexplained meaning or multiple occurrences which could (preferably)...
Read more >
Embedded Debugging with the Black Magic Probe
In a misguided attempt to increase “user-friendliness,” KDbg, Nemiver and the Eclipse IDE hide the GDB console (Eclipse has a console tab in...
Read more >
Options - Untitled - sourceware.org
Repeating non-file options with a different argument will either have no further effect, or override prior occurrences (those further to the left on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found