Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Python's breakpoint and ipdb behave this way? #222

Open
Icarwiz opened this issue Mar 6, 2021 · 1 comment
Open

Why Python's breakpoint and ipdb behave this way? #222

Icarwiz opened this issue Mar 6, 2021 · 1 comment
Labels

Comments

@Icarwiz
Copy link

Icarwiz commented Mar 6, 2021

I apologize in advance if this is not really an issue...

I'm used to debugging in Python with PyCharm.

Now I'm trying to learn using ipdb with Jupyter(Lab to be precise).

But the two following behaviours are really puzzling me !

First one

breakpoint()
for i in range(3):
    print(i)

Then in the debugger :

--Return--
None
> <ipython-input-10-45409e3598c5>(1)<module>()
----> 1 breakpoint()
      2 for i in range(3):
      3     print(i)

ipdb>  n

    [... skipped 1 hidden frame]

    [... skipped 1 hidden frame]

    [... skipped 1 hidden frame]

    [... skipped 1 hidden frame]

> c:\users\icar\anaconda3\envs\jlab3\lib\site-packages\ipython\core\interactiveshell.py(3349)run_ast_nodes()
   3347                     to_run.append((node, 'single'))
   3348 
-> 3349                 for node,mode in to_run:
   3350                     if mode == 'exec':
   3351                         mod = Module([node], [])

Why ipdb next makes ipdb stopping in run_ast_nodes ?

Isn't it supposed to be an equivalent to step over ?

Second one

for i in range(3):
    breakpoint()
    print(i)

Then in the debugger :

None
> <ipython-input-9-2b8431878fa0>(3)<module>()
      1 for i in range(3):
      2     breakpoint()
----> 3     print(i)

ipdb>  c

0
None
> <ipython-input-9-2b8431878fa0>(2)<module>()
      1 for i in range(3):
----> 2     breakpoint()
      3     print(i)

ipdb>  c

1
None
> <ipython-input-9-2b8431878fa0>(3)<module>()
      1 for i in range(3):
      2     breakpoint()
----> 3     print(i)

What can explain ipdb continue alternates stopping on line 3, then 2, then 3 again ?

I guess I'm missing something, but I can't get it, it's just elementary stuff...

@gotcha gotcha added the Question label Mar 8, 2021
@reject-cookies
Copy link

This is happening to me too. But only when ipdb set trace is outside of any function. Very strange.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants