File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -219,13 +219,25 @@ process and user.
219219 :data: `os.environ `, and when one of the :meth: `~dict.pop ` or
220220 :meth: `~dict.clear ` methods is called.
221221
222+ If the :manpage: `clearenv(3)` function is available, the :meth: `~dict.clear ` method
223+ uses it and emits a single ``os._clearenv `` audit event. Otherwise, it emits
224+ an ``os.unsetenv `` event on each deleted variable.
225+
226+ .. audit-event :: os.unsetenv key os.unsetenv
227+
228+ .. audit-event :: os._clearenv "" os._clearenv
229+
222230 .. seealso ::
223231
224232 The :func: `os.reload_environ ` function.
225233
226234 .. versionchanged :: 3.9
227235 Updated to support :pep: `584 `'s merge (``| ``) and update (``|= ``) operators.
228236
237+ .. versionchanged :: 3.15
238+ The :meth: `~dict.clear ` method can now emit an ``os._clearenv `` audit
239+ event.
240+
229241
230242.. data :: environb
231243
Original file line number Diff line number Diff line change 1+ Calling ``os.environ.clear() `` now emits ``os._clearenv `` auditing event.
2+ Patch by Victor Stinner.
Original file line number Diff line number Diff line change @@ -13663,6 +13663,10 @@ static PyObject *
1366313663os__clearenv_impl(PyObject *module)
1366413664/*[clinic end generated code: output=2d6705d62c014b51 input=47d2fa7f323c43ca]*/
1366513665{
13666+ if (PySys_Audit("os._clearenv", NULL) < 0) {
13667+ return NULL;
13668+ }
13669+
1366613670 errno = 0;
1366713671 int err = clearenv();
1366813672 if (err) {
You can’t perform that action at this time.
0 commit comments