python / python/cpython

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

未关闭
#120,513 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

docs topic-free-threading
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

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.

Linked PRs
  • gh-152979

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

查看 issue 中链接的 os.environ 文档,以及会缓存环境的解释器初始化函数的文档。将所要求的线程安全注意事项与链接的 PR gh-152979 进行比较。当两个相关的文档部分都准确描述其他线程修改环境值时的行为时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
documentation, operating-systems
Issue 类型
文档
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。