diff options
author | Steve Dower <steve.dower@python.org> | 2019-11-27 00:27:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-27 00:27:50 (GMT) |
commit | c7c01ab1e5415b772c68e15f1aba51e520010830 (patch) | |
tree | fc3b567daa079723d7419cccfbf35520730c25b8 | |
parent | 0b41a922f95f62b620d5a197b9f2ed8e4bb70730 (diff) | |
download | cpython-c7c01ab1e5415b772c68e15f1aba51e520010830.zip cpython-c7c01ab1e5415b772c68e15f1aba51e520010830.tar.gz cpython-c7c01ab1e5415b772c68e15f1aba51e520010830.tar.bz2 |
bpo-38922: Raise code.__new__ audit event when code object replace() is called (GH-17394)
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2019-11-26-12-20-34.bpo-38922.i6ja-i.rst | 2 | ||||
-rw-r--r-- | Objects/codeobject.c | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-11-26-12-20-34.bpo-38922.i6ja-i.rst b/Misc/NEWS.d/next/Core and Builtins/2019-11-26-12-20-34.bpo-38922.i6ja-i.rst new file mode 100644 index 0000000..a7af652 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-11-26-12-20-34.bpo-38922.i6ja-i.rst @@ -0,0 +1,2 @@ +Calling ``replace`` on a code object now raises the ``code.__new__`` audit +event. diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 39bf6fc..f0b62ec 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -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, |