:data:`os.environ`, and when one of the :meth:`~dict.pop` or
:meth:`~dict.clear` methods is called.
+ If the :manpage:`clearenv(3)` function is available, the :meth:`~dict.clear` method
+ uses it and emits a single ``os._clearenv`` audit event. Otherwise, it emits
+ an ``os.unsetenv`` event on each deleted variable.
+
+ .. audit-event:: os.unsetenv key os.unsetenv
+
+ .. audit-event:: os._clearenv "" os._clearenv
+
.. seealso::
The :func:`os.reload_environ` function.
.. versionchanged:: 3.9
Updated to support :pep:`584`'s merge (``|``) and update (``|=``) operators.
+ .. versionchanged:: 3.15
+ The :meth:`~dict.clear` method can now emit an ``os._clearenv`` audit
+ event.
+
.. data:: environb
os__clearenv_impl(PyObject *module)
/*[clinic end generated code: output=2d6705d62c014b51 input=47d2fa7f323c43ca]*/
{
+ if (PySys_Audit("os._clearenv", NULL) < 0) {
+ return NULL;
+ }
+
errno = 0;
int err = clearenv();
if (err) {