Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Deprecate Windows-to-POSIX separator conversion via PurePosixPath(PureWindowsPath(...))) #125012

Copy link
Copy link
Open
@barneygale

Description

@barneygale
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.