|
9 | 9 |
|
10 | 10 | import debugpy |
11 | 11 | from debugpy import adapter, launcher |
12 | | -from debugpy.common import fmt, json, log, messaging, sockets |
| 12 | +from debugpy.common import compat, fmt, json, log, messaging, sockets |
13 | 13 | from debugpy.common.compat import unicode |
14 | 14 | from debugpy.adapter import components, servers, sessions |
15 | 15 |
|
@@ -272,6 +272,21 @@ def property_or_debug_option(prop_name, flag_name): |
272 | 272 |
|
273 | 273 | return value |
274 | 274 |
|
| 275 | + # "pythonPath" is a deprecated legacy spelling. If "python" is missing, then try |
| 276 | + # the alternative. But if both are missing, the error message should say "python". |
| 277 | + python_key = "python" |
| 278 | + if python_key in request: |
| 279 | + if "pythonPath" in request: |
| 280 | + raise request.isnt_valid( |
| 281 | + '"pythonPath" is not valid if "python" is specified' |
| 282 | + ) |
| 283 | + elif "pythonPath" in request: |
| 284 | + python_key = "pythonPath" |
| 285 | + python = request(python_key, json.array(unicode, vectorize=True, size=(0,))) |
| 286 | + if not len(python): |
| 287 | + python = [compat.filename(sys.executable)] |
| 288 | + request.arguments["pythonArgs"] = python[1:] |
| 289 | + |
275 | 290 | program = module = code = () |
276 | 291 | if "program" in request: |
277 | 292 | program = request("program", unicode) |
@@ -300,7 +315,7 @@ def property_or_debug_option(prop_name, flag_name): |
300 | 315 | args_expansion = request("argsExpansion", json.enum("shell", "none", optional=True)) |
301 | 316 | if args_expansion == "shell": |
302 | 317 | args += request("args", json.array(unicode)) |
303 | | - del request.arguments["args"] |
| 318 | + request.arguments.pop("args", None) |
304 | 319 |
|
305 | 320 | cwd = request("cwd", unicode, optional=True) |
306 | 321 | if cwd == (): |
@@ -330,6 +345,7 @@ def property_or_debug_option(prop_name, flag_name): |
330 | 345 | launchers.spawn_debuggee( |
331 | 346 | self.session, |
332 | 347 | request, |
| 348 | + python, |
333 | 349 | launcher_path, |
334 | 350 | adapter_host, |
335 | 351 | args, |
@@ -537,8 +553,9 @@ def notify_of_subprocess(self, conn): |
537 | 553 | body["name"] = fmt("Subprocess {0}", conn.pid) |
538 | 554 | body["request"] = "attach" |
539 | 555 | body["subProcessId"] = conn.pid |
540 | | - body.pop("processName", None) |
541 | | - body.pop("args", None) |
| 556 | + |
| 557 | + for key in "args", "processName", "pythonArgs": |
| 558 | + body.pop(key, None) |
542 | 559 |
|
543 | 560 | host = body.pop("host", None) |
544 | 561 | port = body.pop("port", None) |
|
0 commit comments