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

(cherry picked from commit c7c01ab1e5)

Co-authored-by: Steve Dower <steve.dower@python.org>
This commit is contained in:
Miss Islington (bot) 2019-11-26 16:46:32 -08:00 committed by GitHub
parent 86d9933cc6
commit 191f94cca6
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
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(
co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals,
co_stacksize, co_flags, (PyObject*)co_code, co_consts, co_names,