Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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. |
Uh oh!
There was an error while loading.Please reload this page.
I suggest to call |
tungol commentedSep 5, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
859aecc intopython:mainUh oh!
There was an error while loading.Please reload this page.
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 commit859aecc)Co-authored-by: Stephen Morton <git@tungol.org>
GH-138777 is a backport of this pull request to the3.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 commit859aecc)Co-authored-by: Stephen Morton <git@tungol.org>
GH-138778 is a backport of this pull request to the3.13 branch. |
Uh oh!
There was an error while loading.Please reload this page.
This corrects a small inconsistency with the error handling of
zoneinfo.reset_tzpath. A sequence ofos.PathLikeinstances 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_tzpathraises TypeError instead of ValueError if passed a sequence with a relative Pathlike #138432