src/eric7/DebugClients/Python/SubprocessExtension.py

branch
eric7-maintenance
changeset 11118
967a88a16a21
parent 11090
f5f5f5803935
diff -r c2cb561a39b0 -r 967a88a16a21 src/eric7/DebugClients/Python/SubprocessExtension.py
--- a/src/eric7/DebugClients/Python/SubprocessExtension.py	Sat Nov 30 11:09:02 2024 +0100
+++ b/src/eric7/DebugClients/Python/SubprocessExtension.py	Tue Jan 14 17:29:56 2025 +0100
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2020 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
+# Copyright (c) 2020 - 2025 Detlev Offenbach <detlev@die-offenbachs.de>
 #
 
 """
@@ -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