python / python/cpython

Clarify os.stat_result.st_mode as int and mention stat earlier in os.stat_result

未關閉
#137,970 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

docs
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Documentation

Issue 1: Clarification that st_mode is an int while octal might be expected

Perhaps the description for st_mode here could use a .. note:: reminding the user that it is an int and a conversion to octal might be needed to see a familiar result.

When checking for file permission bits with os.stat() recently, I noticed the value of the st_mode member of the result was not what I expected - running the program on Unix I expected a familiar value such as 755 to appear at the end of the number. The number looked nothing like that and a quick web search told me I'd need to see that same int in octal notation to see the values I expected. This makes perfect sense after I've learned about it, but I figured maybe a note in the member's description could save someone else a web search.

Issue 2 (related): Moving the reference to the stat module earlier in os.stat_result

I'm also aware now that most such operations should involve the stat module instead of manual parsing of the values. The module is only mentioned at the end of the list of object's members (after st_reparse_tag), while for functions like chflags it is mentioned in the function's description. Could it be moved to the description of os.stat_result? If a user comes looking for a specific member of the os.stat_result object, they are most likely done with reading the member's list once they find it and therefore are unlikely to see the current mention of the module.

Thanks for looking into this!

Linked PRs
  • gh-138532

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 issue 中連結的 os.stat_result.st_mode 文件開始,接著檢視 os.stat_result 周圍的成員列表及其目前的 stat-module 參考文件。完成標準是記錄 st_mode 是一個 int,其常見的權限位元可能需要使用八進位表示,並將 stat-module 的指引提前;開始前檢查已連結的 PR gh-138532。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
documentation
Issue 類型
文件
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。