diff -r bf6be3cff6cf -r a0b6acee2c20 eric6/DebugClients/Python/DebugClientBase.py --- a/eric6/DebugClients/Python/DebugClientBase.py Sun Feb 09 19:27:49 2020 +0100 +++ b/eric6/DebugClients/Python/DebugClientBase.py Mon Feb 10 18:49:49 2020 +0100 @@ -2075,7 +2075,7 @@ def startProgInDebugger(self, progargs, wd='', host=None, port=None, exceptions=True, tracePython=False, - redirect=True): + redirect=True, passive=True): """ Public method used to start the remote debugger. @@ -2090,6 +2090,8 @@ (boolean) @param redirect flag indicating redirection of stdin, stdout and stderr (boolean) + @param passive flag indicating a passive debugging session + @type bool """ if host is None: host = os.getenv('ERICHOST', 'localhost') @@ -2112,8 +2114,9 @@ self.__setCoding(self.running) self.debugging = True - self.passive = True - self.sendPassiveStartup(self.running, exceptions) + self.passive = passive + if passive: + self.sendPassiveStartup(self.running, exceptions) self.__interact() self.attachThread(mainThread=True) @@ -2125,16 +2128,14 @@ self.__interceptSignals() # This will eventually enter a local event loop. - # Note the use of backquotes to cause a repr of self.running. The - # need for this is on Windows os where backslash is the path separator. - # They will get inadvertantly stripped away during the eval causing - # IOErrors if self.running is passed as a normal str. self.debugMod.__dict__['__file__'] = self.running sys.modules['__main__'] = self.debugMod - res = self.mainThread.run( - 'exec(open(' + repr(self.running) + ').read())', - self.debugMod.__dict__) - self.progTerminated(res) + code = self.__compileFileSource(self.running) + if code: + res = self.mainThread.run(code, self.debugMod.__dict__, debug=True) + self.progTerminated(res) + else: + self.progTerminated(42) # should not happen def run_call(self, scriptname, func, *args): """ @@ -2189,6 +2190,7 @@ tracePython = False exceptions = True redirect = True + passive = True while args[0]: if args[0] == '-h': host = args[1] @@ -2222,6 +2224,9 @@ self.fork_auto = True self.fork_child = False del args[0] + elif args[0] == '--no-passive': + passive = False + del args[0] elif args[0] == '--': del args[0] break @@ -2230,6 +2235,9 @@ if not args: print("No program given. Aborting!") # __IGNORE_WARNING_M801__ + elif "-m" in args: + print("Running module as a script is not supported. Aborting!") + # __IGNORE_WARNING_M801__ else: # Store options if a process is spawn # TODO: check which ones are really needed @@ -2242,7 +2250,8 @@ self.startProgInDebugger(args, wd, host, port, exceptions=exceptions, tracePython=tracePython, - redirect=redirect) + redirect=redirect, + passive=passive) else: if sys.argv[1] == '--no-encoding': self.noencoding = True