tungol · GitHub

Bug report

Bug description:

Documentation for zoneinfo.reset_tzpath states:

The to parameter must be a sequence of strings or os.PathLike and not a string, all of which must be absolute paths. ValueError will be raised if something other than an absolute path is passed.

However, the error pathway for relative paths does not currently handle os.PathLike instances correctly.

>>> zoneinfo.reset_tzpath((pathlib.Path("path/to/somewhere"),))
Traceback (most recent call last):
  File "<python-input-6>", line 1, in <module>
    zoneinfo.reset_tzpath((pathlib.Path("path/to/somewhere"),))
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/zoneinfo/_tzpath.py", line 33, in reset_tzpath
    _reset_tzpath(to)
    ~~~~~~~~~~~~~^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/zoneinfo/_tzpath.py", line 17, in _reset_tzpath
    raise ValueError(_get_invalid_paths_message(tzpaths))
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.14/lib/python3.14/zoneinfo/_tzpath.py", line 63, in _get_invalid_paths_message
    indented_str = prefix + prefix.join(invalid_paths)
                            ~~~~~~~~~~~^^^^^^^^^^^^^^^
TypeError: sequence item 0: expected str instance, PosixPath found

CPython versions tested on:

3.14

Operating systems tested on:

macOS

Linked PRs

Read the original on github.com ↗