X Tutup
The Wayback Machine - https://web.archive.org/web/20260305000810/https://github.com/python/cpython/issues/120513
Skip to content

Documentation for os.environ should say that os.environ caching behavior is undefined if other threads are setting environment values #120513

@yurivict

Description

@yurivict

Documentation

It says here:

This mapping is captured the first time the os module is imported, typically during Python startup as part of processing site.py. Changes to the environment made after this time are not reflected in os.environ, except for changes made by modifying os.environ directly.

It should mention the caveat that such cashing would cause undefined behavior or/and crashes when other threads would be setting environment values. This would be true at least on Linux and FreeBSD.

The same should be mentioned in the documentation of the function that initializes the Python interpreter and caches environment.

These functions are not thread-safe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup