--- a/src/eric7/DebugClients/Python/MultiProcessDebugExtension.py Sun Nov 06 11:22:39 2022 +0100 +++ b/src/eric7/DebugClients/Python/MultiProcessDebugExtension.py Mon Nov 07 17:19:58 2022 +0100 @@ -9,6 +9,8 @@ """ import contextlib +import os +import sys from DebugUtilities import ( isPythonProgram, @@ -69,8 +71,6 @@ """ Function replacing the 'execl' functions of the os module. """ - import os - if _shallPatch(): args = patchArguments(_debugClient, args) if isPythonProgram(args[0]): @@ -99,8 +99,6 @@ """ Function replacing the 'execv' functions of the os module. """ - import os - if _shallPatch(): args = patchArguments(_debugClient, args) if isPythonProgram(args[0]): @@ -129,8 +127,6 @@ """ Function replacing the 'execve' functions of the os module. """ - import os - if _shallPatch(): args = patchArguments(_debugClient, args) if isPythonProgram(args[0]): @@ -159,8 +155,6 @@ """ Function replacing the 'spawnl' functions of the os module. """ - import os - args = patchArguments(_debugClient, args) return getattr(os, originalName)(mode, path, *args) @@ -186,8 +180,6 @@ """ Function replacing the 'spawnv' functions of the os module. """ - import os - args = patchArguments(_debugClient, args) return getattr(os, originalName)(mode, path, args) @@ -213,8 +205,6 @@ """ Function replacing the 'spawnve' functions of the os module. """ - import os - args = patchArguments(_debugClient, args) return getattr(os, originalName)(mode, path, args, env) @@ -242,8 +232,6 @@ """ Function replacing the 'posix_spawn' functions of the os module. """ - import os - argv = patchArguments(_debugClient, argv) return getattr(os, originalName)(path, argv, env, **kwargs) @@ -270,7 +258,7 @@ Function replacing the 'fork_exec' functions of the _posixsubprocess module. """ - import _posixsubprocess + import _posixsubprocess # __IGNORE_WARNING_I103__ if _shallPatch(): args = patchArguments(_debugClient, args) @@ -297,9 +285,6 @@ """ Function replacing the 'fork' function of the os module. """ - import os - import sys - # A simple fork will result in a new python process isNewPythonProcess = True frame = sys._getframe() @@ -377,9 +362,9 @@ or _winapi module. """ try: - import _subprocess + import _subprocess # __IGNORE_WARNING_I10__ except ImportError: - import _winapi as _subprocess + import _winapi as _subprocess # __IGNORE_WARNING_I10__ return getattr(_subprocess, originalName)( appName, patchArgumentStringWindows(_debugClient, cmdline), *args ) @@ -403,9 +388,6 @@ # return without patching return - import os - import sys - # patch 'os.exec...()' functions # - patchModule(os, "execl", createExecl) # - patchModule(os, "execle", createExecl) @@ -432,14 +414,14 @@ if isWindowsPlatform(): try: - import _subprocess + import _subprocess # __IGNORE_WARNING_I10__ except ImportError: - import _winapi as _subprocess + import _winapi as _subprocess # __IGNORE_WARNING_I10__ patchModule(_subprocess, "CreateProcess", createCreateProcess) else: patchModule(os, "fork", createFork) with contextlib.suppress(ImportError): - import _posixsubprocess + import _posixsubprocess # __IGNORE_WARNING_I10__ patchModule(_posixsubprocess, "fork_exec", createForkExec)