python / python/cpython

Some ntpath/posixpath functions unusable on foreign OS

未關閉
#119,671 9 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

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

描述

The os.path docs intro includes:

Note: Since different operating systems have different path name conventions, there are several versions of this module in the standard library. The os.path module is always the path module suitable for the operating system Python is running on, and therefore usable for local paths. However, you can also import and use the individual modules if you want to manipulate a path that is always in one of the different formats. They all have the same interface:

  • posixpath for UNIX-style paths
  • ntpath for Windows paths

But we don't explain that some of the functions in ntpath and posixpath aren't suitable for usage on a "foreign" OS, e.g. that using ntpath.realpath() from POSIX is a bad idea.

These functions are safe because they do purely lexical work:

  • basename
  • commonpath
  • commonprefix
  • dirname
  • isabs
  • join
  • normcase
  • normpath
  • split
  • splitdrive
  • splitroot
  • splitext

These functions are probably unsafe because they rely on details of the host OS (e.g. via the os module):

  • abspath
  • exists
  • lexists
  • expanduser
  • expandvars
  • getatime
  • getmtime
  • getctime
  • getsize
  • isfile
  • isdir
  • isjunction
  • islink
  • ismount
  • isdevdrive
  • realpath
  • relpath
  • samefile
  • sameopenfile
  • samestat
  • supports_unicode_filenames
Linked PRs
  • gh-119772

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

從 issue 中連結的 os.path 文件簡介開始,查看詞法函式和相依於主機的函式清單。在進行變更之前,檢查連結的 PR gh-119772。完成的標準是:文件清楚地說明 ntpath 和 posixpath 中哪些函式在其他作業系統上是安全的,以及哪些函式相依於主機作業系統。

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

評估

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

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

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