Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-121957: Emit audit events for python -i and python -m asyncio #121958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Emit cpython.run_stdin in python -i even if PyREPL is not used
  • Loading branch information
ambv committed Jul 18, 2024
commit cf65323c04c6f60b1775391b8cc3877e8bb7dfdb
11 changes: 5 additions & 6 deletions Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,12 @@ static int
pymain_start_pyrepl_no_main(void)
{
int res = 0;
PyObject *pyrepl = NULL;
PyObject *console = NULL;
PyObject *empty_tuple = NULL;
PyObject *kwargs = NULL;
PyObject *console_result = NULL;

if (PySys_Audit("cpython.run_stdin", NULL) < 0) {
res = pymain_exit_err_print();
goto done;
}
pyrepl = PyImport_ImportModule("_pyrepl.main");
PyObject *pyrepl = PyImport_ImportModule("_pyrepl.main");
if (pyrepl == NULL) {
fprintf(stderr, "Could not import _pyrepl.main\n");
res = pymain_exit_err_print();
Expand Down Expand Up @@ -599,6 +594,10 @@ pymain_repl(PyConfig *config, int *exitcode)
return;
}

if (PySys_Audit("cpython.run_stdin", NULL) < 0) {
return;
}

if (!isatty(fileno(stdin))
|| _Py_GetEnv(config->use_environment, "PYTHON_BASIC_REPL")) {
PyCompilerFlags cf = _PyCompilerFlags_INIT;
Expand Down