You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The three sys.path.insert sites in src/debugpy/server/cli.py (run_file, run_module, run_code) are all unconditional. The comments say "like Python itself does" — but CPython skips all three prepends when -I is in effect, so the missing piece is just the interpreter's own flag:
ifnotsys.flags.isolated:
sys.path.insert(0, dir) # resp. str("")
sys.flags.isolated exists since 3.4, so it's safe across all supported versions, and non-isolated runs are untouched. The attach-to-PID injection snippet also inserts a path, but it removes it immediately after import, so I'd leave that one alone.
I'd like to take this — will put up a PR with the three guards plus a regression test that runs the debuggee under -I for all three run modes and asserts the script dir / cwd is not prepended.
Activity
karandhaodiyal28-hash commentedon Jul 30, 2026
Reproduced on Windows 11 / Python 3.12 / debugpy 1.8.x against current
main:The three
sys.path.insertsites insrc/debugpy/server/cli.py(run_file,run_module,run_code) are all unconditional. The comments say "like Python itself does" — but CPython skips all three prepends when-Iis in effect, so the missing piece is just the interpreter's own flag:sys.flags.isolatedexists since 3.4, so it's safe across all supported versions, and non-isolated runs are untouched. The attach-to-PID injection snippet also inserts a path, but it removes it immediately after import, so I'd leave that one alone.I'd like to take this — will put up a PR with the three guards plus a regression test that runs the debuggee under
-Ifor all three run modes and asserts the script dir / cwd is not prepended.