Sun, 27 Jan 2013 16:34:50 +0100
Fixed some more bugs in the Python2 and Python3 debug clients.
(grafted from a0409e65bd813de5f9f94f54cb74989f0aefd5c1)
DebugClients/Python/DebugClientBase.py | file | annotate | diff | comparison | revisions | |
DebugClients/Python3/DebugClientBase.py | file | annotate | diff | comparison | revisions |
--- a/DebugClients/Python/DebugClientBase.py Sat Jan 26 12:44:46 2013 +0100 +++ b/DebugClients/Python/DebugClientBase.py Sun Jan 27 16:34:50 2013 +0100 @@ -555,8 +555,14 @@ self.debugMod.__dict__['__file__'] = sys.argv[0] sys.modules['__main__'] = self.debugMod - execfile(sys.argv[0], self.debugMod.__dict__) + res = 0 + try: + execfile(sys.argv[0], self.debugMod.__dict__) + except SystemExit as exc: + res = exc.code + atexit._run_exitfuncs() self.writestream.flush() + self.progTerminated(res) return if cmd == DebugProtocol.RequestCoverage: @@ -585,16 +591,20 @@ self.cover.erase() sys.modules['__main__'] = self.debugMod self.debugMod.__dict__['__file__'] = sys.argv[0] + self.running = sys.argv[0] + res = 0 self.cover.start() try: execfile(sys.argv[0], self.debugMod.__dict__) - except SystemExit: + except SystemExit as exc: + res = exc.code atexit._run_exitfuncs() self.cover.stop() self.cover.save() self.writestream.flush() + self.progTerminated(res) return - + if cmd == DebugProtocol.RequestProfile: sys.setprofile(None) import PyProfile @@ -620,9 +630,16 @@ self.prof.erase() self.debugMod.__dict__['__file__'] = sys.argv[0] sys.modules['__main__'] = self.debugMod - self.prof.run('execfile(%r)' % sys.argv[0]) + self.running = sys.argv[0] + res = 0 + try: + self.prof.run('execfile(%r)' % sys.argv[0]) + except SystemExit as exc: + res = exc.code + atexit._run_exitfuncs() self.prof.save() self.writestream.flush() + self.progTerminated(res) return if cmd == DebugProtocol.RequestShutdown:
--- a/DebugClients/Python3/DebugClientBase.py Sat Jan 26 12:44:46 2013 +0100 +++ b/DebugClients/Python3/DebugClientBase.py Sun Jan 27 16:34:50 2013 +0100 @@ -542,9 +542,15 @@ self.debugMod.__dict__['__file__'] = sys.argv[0] sys.modules['__main__'] = self.debugMod - exec(open(sys.argv[0], encoding=self.__coding).read(), - self.debugMod.__dict__) + res = 0 + try: + exec(open(sys.argv[0], encoding=self.__coding).read(), + self.debugMod.__dict__) + except SystemExit as exc: + res = exc.code + atexit._run_exitfuncs() self.writestream.flush() + self.progTerminated(res) return if cmd == DebugProtocol.RequestProfile: @@ -578,9 +584,18 @@ finally: fp.close() if script: - self.prof.run("exec({0!r}\n)".format(script)) + if not script.endswith('\n'): + script += '\n' + self.running = sys.argv[0] + res = 0 + try: + self.prof.run(script) + except SystemExit as exc: + res = exc.code + atexit._run_exitfuncs() self.prof.save() self.writestream.flush() + self.progTerminated(res) return if cmd == DebugProtocol.RequestCoverage: @@ -618,14 +633,18 @@ if not script.endswith('\n'): script += '\n' code = compile(script, sys.argv[0], 'exec') + self.running = sys.argv[0] + res = 0 self.cover.start() try: exec(code, self.debugMod.__dict__) - except SystemExit: + except SystemExit as exc: + res = exc.code atexit._run_exitfuncs() self.cover.stop() self.cover.save() self.writestream.flush() + self.progTerminated(res) return if cmd == DebugProtocol.RequestShutdown: