Skip to content

GH-99334: Explain that PurePath.is_relative_to() is purely lexical. #114031

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

barneygale
Copy link
Contributor

@barneygale barneygale commented Jan 13, 2024

@barneygale barneygale added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jan 13, 2024
Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could add a note that users may wish to only call it with resolved / normalised / casefolded / etc paths, and provide a brief sketch of doing so?

@barneygale
Copy link
Contributor Author

Thanks for the review!

Perhaps you could add a note that users may wish to only call it with resolved / normalised / casefolded / etc paths, and provide a brief sketch of doing so?

It's hard to give good advice, because there are several edge cases that may or may not be relevant depending on user need. resolve() only emulates (perhaps imperfectly) what the OS does to resolve paths, and there's a TOC/TOU thing because someone could swap a symlink target in the path immediately after you call it.

(tbh I'd rather is_relative_to() didn't exist, but we're here now)

@AA-Turner
Copy link
Member

I think the actual change here is fine to merge -- the comment was just the cherry on top, but it would simply add confusion then best avoided -- and the reader can infer that no path processing is done from the current text as proposed.

A

@barneygale
Copy link
Contributor Author

Thanks again!

@barneygale barneygale merged commit 3a61d24 into python:main Jan 23, 2024
@miss-islington-app
Copy link

Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 23, 2024
…xical. (pythonGH-114031)

(cherry picked from commit 3a61d24)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
@miss-islington-app
Copy link

Sorry, @barneygale, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 3a61d24062aaa1e13ba794360b6c765d9a1f2b06 3.11

@bedevere-app
Copy link

bedevere-app bot commented Jan 23, 2024

GH-114460 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Jan 23, 2024
barneygale added a commit to barneygale/cpython that referenced this pull request Jan 23, 2024
barneygale added a commit to barneygale/cpython that referenced this pull request Jan 23, 2024
…rely lexical. (pythonGH-114031).

(cherry picked from commit 3a61d24)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 23, 2024

GH-114461 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Jan 23, 2024
barneygale pushed a commit that referenced this pull request Jan 23, 2024
barneygale added a commit that referenced this pull request Jan 23, 2024
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news topic-pathlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants