bpo-38922: Raise code.__new__ audit event when code object replace() is called (GH-17394)

This commit is contained in:
Steve Dower 2019-11-26 16:27:50 -08:00 committed by GitHub
parent 0b41a922f9
commit c7c01ab1e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Calling ``replace`` on a code object now raises the ``code.__new__`` audit
event.

View File

@ -641,6 +641,13 @@ code_replace_impl(PyCodeObject *self, int co_argcount,
#undef CHECK_INT_ARG #undef CHECK_INT_ARG
if (PySys_Audit("code.__new__", "OOOiiiiii",
co_code, co_filename, co_name, co_argcount,
co_posonlyargcount, co_kwonlyargcount, co_nlocals,
co_stacksize, co_flags) < 0) {
return NULL;
}
return (PyObject *)PyCode_NewWithPosOnlyArgs( return (PyObject *)PyCode_NewWithPosOnlyArgs(
co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals,
co_stacksize, co_flags, (PyObject*)co_code, co_consts, co_names, co_stacksize, co_flags, (PyObject*)co_code, co_consts, co_names,