From ca54f2099dbdac3a5a0734d9e2cf7e18c6eeb843 Mon Sep 17 00:00:00 2001 From: Luke Riddle Date: Tue, 3 Dec 2024 07:18:13 -0800 Subject: [PATCH] Fix path modification for windows filesystems that can't handle .. --- src/debugpy/adapter/__main__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/debugpy/adapter/__main__.py b/src/debugpy/adapter/__main__.py index e18ecd560..dd784cb57 100644 --- a/src/debugpy/adapter/__main__.py +++ b/src/debugpy/adapter/__main__.py @@ -211,7 +211,13 @@ def _parse_argv(argv): # future imports of it or its submodules will resolve accordingly. if "debugpy" not in sys.modules: # Do not use dirname() to walk up - this can be a relative path, e.g. ".". - sys.path[0] = sys.path[0] + "/../../" + if os.name == "nt": + import pathlib + + windows_path = pathlib.Path(sys.path[0]) + sys.path[0] = str(windows_path.parent.parent) + else: + sys.path[0] = sys.path[0] + "/../../" __import__("debugpy") del sys.path[0]