From e8efe6199c00a7cf6ea3b483f6e4b18816d02ec7 Mon Sep 17 00:00:00 2001 From: hrimov Date: Fri, 3 Jul 2026 21:35:54 +0200 Subject: [PATCH] Add thread-safety warning to os.environ docs --- Doc/library/os.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 7b043f257ca0b5..a7aa0c5fd14f96 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -214,6 +214,11 @@ process and user. cause memory leaks. Refer to the system documentation for :c:func:`!putenv`. + .. warning:: + Setting or unsetting environment variables from one thread while + another thread reads or writes them is not guaranteed to be + thread-safe and can crash the process on some platforms. + You can delete items in this mapping to unset environment variables. :func:`unsetenv` will be called automatically when an item is deleted from :data:`os.environ`, and when one of the :meth:`~dict.pop` or