Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

zoneinfo.reset_tzpath raises TypeError instead of ValueError if passed a sequence with a relative Pathlike #138432

Open
Labels
stdlibStandard Library Python modules in the Lib/ directory type-bugAn unexpected behavior, bug, or error
@tungol

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directory type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /