]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38922: Raise code.__new__ audit event when code object replace() is called (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 27 Nov 2019 00:46:32 +0000 (16:46 -0800)
committerGitHub <noreply@github.com>
Wed, 27 Nov 2019 00:46:32 +0000 (16:46 -0800)
(cherry picked from commit c7c01ab1e5415b772c68e15f1aba51e520010830)

Co-authored-by: Steve Dower <steve.dower@python.org>
Misc/NEWS.d/next/Core and Builtins/2019-11-26-12-20-34.bpo-38922.i6ja-i.rst [new file with mode: 0644]
Objects/codeobject.c

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 (file)
index 0000000..a7af652
--- /dev/null
@@ -0,0 +1,2 @@
+Calling ``replace`` on a code object now raises the ``code.__new__`` audit
+event.
index 39bf6fc6f228e7fddc1b88da9a5375b09485a763..f0b62ec94148d66f05a3eef485e6353fa1dd13e7 100644 (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,