Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

pathlib.PurePath.relative_to(walk_up=True) mishandles '..' components #105002

Closed
Labels
3.12only security fixes3.13bugs and security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or error
@barneygale

Description

@barneygale

pathlib.PurePath.relative_to(other, walk_up=True) doesn't handle '..' segments in itsother argument correctly:

>>>frompathlibimportPurePath,Path>>>Path.cwd()PosixPath('/home/barney/projects/cpython')>>>PurePath('a/b').relative_to('a/..',walk_up=True)PurePosixPath('../b')# expected: ValueError (ideal world: 'a/b')>>>PurePath('a/b').relative_to('a/../..',walk_up=True)PurePosixPath('../../b')# expected: ValueError (ideal world: 'cpython/a/b')

PurePath objects do not know the current working directory, nor can they safely eliminate.. segments without resolving symlinks, so I think raisingValueError is the only reasonable thing to do.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp