mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-138432: Improved invalid path checking in zoneinfo.reset_tzpath() (GH-138433)
* Improve error messages for path-like relative paths and path-like bytes paths. * TZPATH is now always a tuple of strings.
This commit is contained in:
parent
d0c9943869
commit
859aecc33b
3 changed files with 23 additions and 1 deletions
|
|
@ -13,6 +13,13 @@ def _reset_tzpath(to=None, stacklevel=4):
|
|||
+ f"not {type(tzpaths)}: {tzpaths!r}"
|
||||
)
|
||||
|
||||
tzpaths = [os.fspath(p) for p in tzpaths]
|
||||
if not all(isinstance(p, str) for p in tzpaths):
|
||||
raise TypeError(
|
||||
"All elements of a tzpath sequence must be strings or "
|
||||
"os.PathLike objects which convert to strings."
|
||||
)
|
||||
|
||||
if not all(map(os.path.isabs, tzpaths)):
|
||||
raise ValueError(_get_invalid_paths_message(tzpaths))
|
||||
base_tzpath = tzpaths
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue