src/eric7/DebugClients/Python/SubprocessExtension.py

branch
eric7
changeset 11088
0299c9ba1c6f
parent 10633
dda7e43934dc
child 11090
f5f5f5803935
diff -r 8f5d1b5e16c9 -r 0299c9ba1c6f src/eric7/DebugClients/Python/SubprocessExtension.py
--- a/src/eric7/DebugClients/Python/SubprocessExtension.py	Fri Dec 06 09:12:46 2024 +0100
+++ b/src/eric7/DebugClients/Python/SubprocessExtension.py	Fri Dec 06 14:16:23 2024 +0100
@@ -10,6 +10,7 @@
 
 import os
 import shlex
+import shutil
 
 from DebugUtilities import (
     isPythonProgram,
@@ -55,22 +56,37 @@
             ):
                 if isinstance(args, str):
                     # convert to arguments list
-                    args = (
+                    args_list = (
                         stringToArgumentsWindows(args)
                         if isWindowsPlatform()
                         else shlex.split(args)
                     )
                 else:
                     # create a copy of the arguments
-                    args = args[:]
-                ok = isPythonProgram(args[0])
-                if ok:
-                    scriptName = os.path.basename(args[0])
+                    args_list = args[:]
+                isPythonProg = isPythonProgram(
+                    args_list[0],
+                    withPath="shell" in kwargs and kwargs["shell"] is True,
+                )
+                if isPythonProg:
+                    scriptName = os.path.basename(args_list[0])
                     if not _debugClient.skipMultiProcessDebugging(scriptName):
-                        args = patchArguments(_debugClient, args, noRedirect=True)
-                    if "shell" in kwargs and kwargs["shell"] is True:
-                        # shell=True interferes with eric debugger
-                        kwargs["shell"] = False
+                        if (
+                            "shell" in kwargs
+                            and kwargs["shell"] is True
+                            and not os.path.isabs(args_list[0])
+                        ):
+                            prog = shutil.which(args_list[0])
+                            if prog:
+                                args_list[0] = prog
+                        args = patchArguments(
+                            _debugClient,
+                            args_list,
+                            noRedirect=True,
+                            isPythonProg=isPythonProg,
+                        )
+                        if "shell" in kwargs and kwargs["shell"] is True:
+                            args = shlex.join(args)
 
             super().__init__(args, *popenargs, **kwargs)
 

eric ide

mercurial