Skip to content

Commit d694a42

Browse files
committed
Fix failing tests
1 parent b064943 commit d694a42

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/debugpy/adapter/launchers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def on_launcher_connected(sock):
166166
if args[i] == "--":
167167
break
168168
s = args[i]
169-
if " " in s and not (s.startswith('"') and s.endswith('"')) or (s.startswith("'") and s.endswith("'")):
169+
if " " in s and not ((s.startswith('"') and s.endswith('"')) or (s.startswith("'") and s.endswith("'"))):
170170
s = f"{quote_char}{s}{quote_char}"
171171
args[i] = s
172172

tests/debug/session.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,18 +366,29 @@ def _make_env(self, base_env, codecov=True):
366366
return env
367367

368368
def _make_python_cmdline(self, exe, *args):
369-
def normalize(s):
369+
def normalize(s, strip_quotes=False):
370370
# Convert py.path.local to string
371371
if isinstance(s, py.path.local):
372372
s = s.strpath
373373
else:
374374
s = str(s)
375-
# Strip surrounding quotes if present
376-
if len(s) >= 2 and (s[0] == s[-1] == '"' or s[0] == s[-1] == "'"):
375+
# Strip surrounding quotes if requested (for launcher args only)
376+
if strip_quotes and len(s) >= 2 and (s[0] == s[-1] == '"' or s[0] == s[-1] == "'"):
377377
s = s[1:-1]
378378
return s
379379

380-
return [normalize(x) for x in (exe, *args)]
380+
# Strip quotes from exe and args before '--', but not from debuggee args after '--'
381+
# (exe and launcher paths may be quoted when argsCanBeInterpretedByShell is set)
382+
result = [normalize(exe, strip_quotes=True)]
383+
found_separator = False
384+
for arg in args:
385+
if arg == "--":
386+
found_separator = True
387+
result.append(arg)
388+
else:
389+
# Strip quotes before '--', but not after (debuggee args)
390+
result.append(normalize(arg, strip_quotes=not found_separator))
391+
return result
381392

382393
def spawn_debuggee(self, args, cwd=None, exe=sys.executable, setup=None):
383394
assert self.debuggee is None

0 commit comments

Comments
 (0)