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

VS Code ignores breakpoints in the importlib module #1676

Closed
Andrej730 opened this issue Jun 27, 2024 · 3 comments
Closed

VS Code ignores breakpoints in the importlib module #1676

Andrej730 opened this issue Jun 27, 2024 · 3 comments
Labels
needs repro Issue has not been reproduced yet

Comments

@Andrej730
Copy link

Andrej730 commented Jun 27, 2024

How to reproduce:

  1. Disable justmycode for debugpy (in my case it's disabled both in user and workspace settings).
    image

  2. Create an empty python file.

  3. Open Python\Lib\importlib\__init__.py and insert a breakpoint. You can add some print statement to get sense when we're past the breakpoint.

image

  1. Start debug for an empty python file with the "Python Debugger: Debug Python file".
    image

  2. Script will be executed but breakpoint is never triggered - though there will be print messages we added on step 3.

As a workaround it's possible to debug it with the classic breakpoint() though it's not as convenient.

@paulacamargo25
Copy link

paulacamargo25 commented Jul 18, 2024

We do not handle breakpoint in the extension, I am not sure if this a vscode error or debugpy, sending it to debugpy.

@paulacamargo25 paulacamargo25 removed their assignment Jul 18, 2024
@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python-debugger Sep 18, 2024
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Sep 18, 2024
@judej judej assigned debonte and unassigned judej and debonte Oct 14, 2024
@judej
Copy link

judej commented Oct 23, 2024

@Andrej730, the issue is due to the way python optimizes the loading of the standard modules. The breakpoint() function or debugpy.breakpoint() are often the most reliable methods for debugging such scenarios.

You could also try attaching to the process and stepping into imporlib code,

Hope that helps.

@judej judej closed this as completed Oct 23, 2024
@rchiodo
Copy link
Contributor

rchiodo commented Oct 23, 2024

I believe this is a special case. Debugpy uses importlib itself. We can't debug modules that are already loaded into the debugger by the debugger. Sticking a breakpoint() in the code doesn't work for me either. It just hangs launching the debugger (well because it's using importlib).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

5 participants