gh-121957: Emit audit events for python -i and python -m asyncio (GH-121958)

Relatedly, emit the `cpython.run_startup` event from the Python version of
`PYTHONSTARTUP` handling.
This commit is contained in:
Łukasz Langa 2024-07-22 13:04:08 +02:00 committed by GitHub
parent cad11a2bdc
commit dc93d1125f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 36 additions and 2 deletions

View file

@ -39,6 +39,8 @@ def interactive_console(mainmodule=None, quiet=False, pythonstartup=False):
# sys._baserepl() above does this internally, we do it here
startup_path = os.getenv("PYTHONSTARTUP")
if pythonstartup and startup_path:
sys.audit("cpython.run_startup", startup_path)
import tokenize
with tokenize.open(startup_path) as f:
startup_code = compile(f.read(), startup_path, "exec")