https://github.com/python/cpython/commit/ac5424d6a9f5aa37432cbbf366745f708f44a8ec
commit: ac5424d6a9f5aa37432cbbf366745f708f44a8ec
branch: main
author: Victor Stinner <vstin...@python.org>
committer: vstinner <vstin...@python.org>
date: 2025-04-25T18:30:39+02:00
summary:

gh-107954: Add audit event to PyConfig_Set() (#132958)

files:
M Doc/c-api/init_config.rst
M Python/initconfig.c

diff --git a/Doc/c-api/init_config.rst b/Doc/c-api/init_config.rst
index d8d442cff03f3c..bc5b236393be15 100644
--- a/Doc/c-api/init_config.rst
+++ b/Doc/c-api/init_config.rst
@@ -619,6 +619,8 @@ Some options are read from the :mod:`sys` attributes. For 
example, the option
    The caller must have an :term:`attached thread state`. The function cannot
    be called before Python initialization nor after Python finalization.
 
+   .. audit-event:: cpython.PyConfig_Set name,value c.PyConfig_Set
+
    .. versionadded:: 3.14
 
 
diff --git a/Python/initconfig.c b/Python/initconfig.c
index 43b85a383d3bb2..7d3043dd5d1dd9 100644
--- a/Python/initconfig.c
+++ b/Python/initconfig.c
@@ -4539,6 +4539,10 @@ config_set_int_attr(const PyConfigSpec *spec, int value)
 int
 PyConfig_Set(const char *name, PyObject *value)
 {
+    if (PySys_Audit("cpython.PyConfig_Set", "sO", name, value) < 0) {
+        return -1;
+    }
+
     const PyConfigSpec *spec = config_find_spec(name);
     if (spec == NULL) {
         spec = preconfig_find_spec(name);

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to