Deprecate Windows-to-POSIX separator conversion via `PurePosixPath(PureWindowsPath(...)))`
未关闭
还没有人认领这个 Issue。
topic-pathlib
type-feature
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
Feature or enhancement
This was probably never an intentional feature, and results in subtle behaviour:
>>> from pathlib import PurePosixPath, PureWindowsPath
>>> from os import fspath
>>> p = PureWindowsPath('foo', 'bar')
>>> PurePosixPath(p)
PurePosixPath('foo/bar')
>>> p = fspath(p)
>>> PurePosixPath(p)
PurePosixPath('foo\\bar')
PurePath is documented as accepting os.PathLike objects, and so the additional os.fspath() call shouldn't really make a difference. See #103631 for why it does (spoiler: backwards-compatibility).
Folks can use PurePosixPath(PureWindowsPath().as_posix()) instead, which makes it more explicit that backwards-to-forwards slash conversion is desired.
Linked PRs
- gh-125863
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先查看 issue 和链接的 PR gh-125863 中描述的 pathlib PurePath 处理方式。比较 PureWindowsPath 和 PurePosixPath 的示例,然后确认已弃用的转换行为和显式替代方案 as_posix() 已包含在所产生的更改中。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- operating-systems
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100