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

Breakpoints are not hit when cell source begins with empty lines #11532

Open
kycutler opened this issue Nov 23, 2021 · 3 comments
Open

Breakpoints are not hit when cell source begins with empty lines #11532

kycutler opened this issue Nov 23, 2021 · 3 comments
Assignees

Comments

@kycutler
Copy link

Description

When connected to a debuggable kernel (this reproduces with both latest ipykernel and xpython), breakpoints in a cell that begins with one or more "empty" lines (whitespace only) will never be hit. Removing the lines and re-running the cell fixes the issue.

image

Reproduce

  1. Create a new notebook
  2. Connect to a debuggable kernel and enable the debugger
  3. Add one or more empty lines to the cell, followed by some code (e.g. print("hello world")) and set a breakpoint on the line with code
  4. Run the cell
  5. Notice that execution does not pause on the breakpoint

Expected behavior

The breakpoint should be hit regardless of leading newlines

Context

  • Operating System and version: Windows 11
  • Browser and version: Edge 95
  • JupyterLab version: 3.2.4
@kycutler kycutler added the bug label Nov 23, 2021
@welcome
Copy link

welcome bot commented Nov 23, 2021

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@kycutler
Copy link
Author

Testing this a bit more, it seems the initial empty lines are not counted toward line numbers in the debugger. Breakpoints can still be hit if they are on a line number that is less than the number of lines after the initial empty ones. For example with three non-empty lines they can be hit up to line three:

image

image

Notice also that the outputs indicate that we are actually on print(3) since 1 and 2 have been printed already. So it seems just the line numbers are wrong.

@fcollonval
Copy link
Member

The reason for this bug is the cleanup transformation applied by IPython:

https://github.com/ipython/ipython/blob/c5102802380809adfdb980dafd041d99c5c9e299/IPython/core/inputtransformer2.py#L571

One of those cleanup transformation removes the leading empty lines. I pushed a fix to ipykernel that deactivates that cleanup transformation when a debug session is active (PR link above this comment).

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

No branches or pull requests

3 participants