Skip to content
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

gh-117584: Raise TypeError for non-paths in posixpath.relpath() #117585

Merged
merged 5 commits into from
Apr 7, 2024

Conversation

nineteendo
Copy link
Contributor

@nineteendo nineteendo commented Apr 6, 2024

@nineteendo nineteendo marked this pull request as ready for review April 6, 2024 16:43
…e-117584.hqk9Hn.rst

Co-authored-by: AN Long <aisk@users.noreply.github.com>
@aisk
Copy link
Contributor

aisk commented Apr 6, 2024

If the ValueError is raised by if not path: check, the falsy values 0 and [] will also raise the same ValueError, which is also strange. Maybe we can change the check to if path == "".

nineteendo and others added 2 commits April 6, 2024 18:53
….gh-issue-117584.hqk9Hn.rst"

This reverts commit 27d0c70.
…e-117584.hqk9Hn.rst

Co-authored-by: AN Long <aisk@users.noreply.github.com>
@nineteendo
Copy link
Contributor Author

No we can not, that doesn't work for Pathlike objects nor bytes.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@serhiy-storchaka serhiy-storchaka merged commit 733e56e into python:main Apr 7, 2024
35 checks passed
@nineteendo nineteendo deleted the fix-posixpath.relpath branch April 7, 2024 11:16
@nineteendo
Copy link
Contributor Author

@serhiy-storchaka can we back port this to 3.12? It's a pure bug fix.

@bedevere-app
Copy link

bedevere-app bot commented May 22, 2024

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

@serhiy-storchaka
Copy link
Member

I do not think this is a bug fix. Normally you should not pass None to relpath(), so this does not affect most of applications. If for some reasons you passed an argument of wrong type without checking it, and handle the resulting ValueError, changing the exception type to TypeError is a breaking change. Even if it is right in the long run, it should not be done is the bugfix release.

@nineteendo
Copy link
Contributor Author

Thanks, closed the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants