gh-138432: zoneinfo: improve error message for PathLike relative paths#138433
gh-138432: zoneinfo: improve error message for PathLike relative paths#138433serhiy-storchaka merged 8 commits intopython:mainfrom
Conversation
StanFromIreland
left a comment
There was a problem hiding this comment.
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? |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Thank you for your response @tungol. Yes, this is what I suggested.
Few more nitpicks.
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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 <[email protected]>
|
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 <[email protected]>
|
GH-138778 is a backport of this pull request to the 3.13 branch. |
…path() (GH-138433) (GH-138778) * 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 <[email protected]>
…path() (GH-138433) (GH-138777) * 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 <[email protected]>
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