mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: CG trace: Handle SystemExit
otherwise, with-exit would end the tracer without producing any output :|
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import sys
|
||||
|
||||
print("will exit now")
|
||||
|
||||
sys.exit()
|
||||
@@ -173,12 +173,15 @@ class CallGraphTracer:
|
||||
try:
|
||||
sys.setprofile(self.profilefunc)
|
||||
exec(code, globals, locals)
|
||||
sys.setprofile(None)
|
||||
return "completed"
|
||||
except SystemExit:
|
||||
return "completed (SystemExit)"
|
||||
except Exception:
|
||||
sys.setprofile(None)
|
||||
LOGGER.info("Exception occurred while running program:", exc_info=True)
|
||||
return "exception occurred"
|
||||
finally:
|
||||
sys.setprofile(None)
|
||||
|
||||
def profilefunc(self, frame: FrameType, event: str, arg):
|
||||
# ignore everything until the first call, since that is `exec` from the `run`
|
||||
|
||||
Reference in New Issue
Block a user