-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
gh-138432: zoneinfo: improve error message for PathLike relative paths #138433
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a news entry.
Done. |
I suggest to call |
We can do that, but I don't think it's really necessary. Checking for absolute status is done with I found this issue while working on a program to apply typeshed stubs to the stdlib and then analyze with mypy, so I'm relatively confident that this is the only place in (python-source) stdlib where os.Pathlike values for TZPATH were overlooked. (Typeshed correctly annotates TZPATH as This leaves the possibility of third-party consumers of TZPATH being surprised by encountering an |
It will help to check that if it is a path-like object, it is Anyway, if os.fspath() is already implicitly called in |
@serhiy-storchaka Is this about what you were thinking? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your response @tungol. Yes, this is what I suggested.
Few more nitpicks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
Thank you for your contribution.
Thanks @tungol for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks @tungol for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
Sorry, @tungol and @serhiy-storchaka, I could not cleanly backport this to
|
…ath() (pythonGH-138433) * Improve error messages for path-like relative paths and path-like bytes paths. * TZPATH is now always a tuple of strings. (cherry picked from commit 859aecc) Co-authored-by: Stephen Morton <git@tungol.org>
GH-138777 is a backport of this pull request to the 3.14 branch. |
…set_tzpath() (pythonGH-138433) * Improve error messages for path-like relative paths and path-like bytes paths. * TZPATH is now always a tuple of strings. (cherry picked from commit 859aecc) Co-authored-by: Stephen Morton <git@tungol.org>
GH-138778 is a backport of this pull request to the 3.13 branch. |
This corrects a small inconsistency with the error handling of
zoneinfo.reset_tzpath
. A sequence ofos.PathLike
instances is documented as valid input, but the error pathway for relative paths doesn't handle these correctly. This pull request corrects this, and adds a relevant test case.zoneinfo.reset_tzpath
raises TypeError instead of ValueError if passed a sequence with a relative Pathlike #138432