eric6/DebugClients/Python/DebugUtilities.py

branch
multi_processing
changeset 7873
cb2badbdf26c
parent 7871
eb65864ca038
child 7892
bd6b9e401166
--- a/eric6/DebugClients/Python/DebugUtilities.py	Sat Dec 12 15:30:05 2020 +0100
+++ b/eric6/DebugClients/Python/DebugUtilities.py	Sun Dec 13 19:54:19 2020 +0100
@@ -195,6 +195,8 @@
                     for name in PYTHON_NAMES:
                         if line.startswith('#!/usr/bin/env {0}'.format(name)):
                             return True
+                        elif line.startswith('#!') and name in line:
+                            return True
                     return False
     except UnicodeDecodeError:
         return False
@@ -287,6 +289,12 @@
     @return modified argument list
     @rtype list of str
     """
+    debugClientScript = os.path.join(
+        os.path.dirname(__file__), "DebugClient.py")
+    if debugClientScript in arguments:
+        # it is already patched
+        return arguments
+    
     args = list(arguments[:])    # create a copy of the arguments list
     args = removeQuotesFromArgs(args)
     
@@ -299,6 +307,9 @@
         if not isWindowsPlatform() and startsWithShebang(args[0]):
             # insert our interpreter as first argument
             args.insert(0, sys.executable)
+        elif isWindowsPlatform() and args[0].lower().endswith(".py"):
+            # it is a Python script; insert our interpreter as first argument
+            args.insert(0, sys.executable)
     
     # check for -m invocation => debugging not supported yet
     if "-m" in args:
@@ -346,7 +357,7 @@
     modifiedArguments = [interpreter]
     modifiedArguments.extend(interpreterArgs)
     modifiedArguments.extend([
-        os.path.join(os.path.dirname(__file__), "DebugClient.py"),
+        debugClientScript,
         "-h", host,
         "-p", str(port),
         "--no-passive",

eric ide

mercurial