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

Using pyfakefs breaks vscode's debugger #1083

Open
Aran-Fey opened this issue Oct 22, 2024 · 12 comments
Open

Using pyfakefs breaks vscode's debugger #1083

Aran-Fey opened this issue Oct 22, 2024 · 12 comments

Comments

@Aran-Fey
Copy link

Using pyfakefs leads to a variety of issues with vscode's debugger, like breakpoints not working and duplicate file tabs being opened. I made a bug report here, but the folks at debugpy have decided it's not their responsibility to fix it. Can you guys take care of it?

@Aran-Fey
Copy link
Author

This may only be an issue if PatchMode.AUTO is used, now that I think about it.

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Oct 22, 2024

Yeah, PatchMode.AUTO may have unwanted side effects and probably won't play nice with a debugger, as that relies on loading code on a low level.
If this indeed only happens if patching open_code, there is probably not much we can do with reasonable effort. I don't think I want to go down that rabbit hole...

@mrbean-bremen
Copy link
Member

@Aran-Fey - can you confirm that this only happens with PatchMode.AUTO?

@Aran-Fey
Copy link
Author

Actually, nope. A duplicate tab is opened regardless of the PatchMode, and the breakpoints continue to sometimes be ignored without any apparent reason.

@mrbean-bremen
Copy link
Member

Ok, thanks. I'm not using VSCode (I use PyCharm), so it may take a while to understand this. Do you have a way to reproduce this with some minimal example?

@Aran-Fey
Copy link
Author

This seems to do it:

import typing

def test_demo(fs):
    typing.get_type_hints(int)
  1. Set a breakpoint at typing.get_type_hints(int) -> breakpoint is hit, duplicate file tab is opened
  2. Set a breakpoint inside of get_type_hints -> breakpoint is ignored
  3. Remove fs fixture: Both issues go away

@mrbean-bremen
Copy link
Member

Thanks, I will give it a try!

@mrbean-bremen
Copy link
Member

You are working with the current pyfakefs version (5.7.1), right?

@mrbean-bremen
Copy link
Member

Ah, and which Python version are you using?

@Aran-Fey
Copy link
Author

Correction: Only the duplicate tab issue goes away. Having some trouble reproducing the breakpoint issue. If I replace typing with a custom-made python module, the breakpoint is hit as expected. Maybe breakpoints don't work in the stdlib or something, or maybe it's just the bug being janky again. Really not sure.

I'm using pyfakefs 5.7.1 and cpython 3.10.13.

@mrbean-bremen
Copy link
Member

So far, I have not been able to get sensible behavior even in tests without pyfakefs - I guess I have to better understand the workflow in VSCode first... Will have another go over the weekend.

@mrbean-bremen
Copy link
Member

Ok, I persuaded VSCode to work for me, and I can reproduce the duplicate tab behavior now (not the ignored breakpoint so far). At the moment, I have no idea where to even look, so no promises...

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

No branches or pull requests

2 participants