Visitar URL original
GH-103525: Improve exception message from `pathlib.PurePath()` by barneygale · Pull Request #103526 · python/cpython · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Lib/pathlib.py
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
  • Loading branch information
barneygale and terryjreedy authored Apr 13, 2023
commit d24465e5af405aee956f7177ea1211ba3c27ca59
5 changes: 4 additions & 1 deletion Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ def __init__(self, *args):
if isinstance(arg, PurePath):
path = arg._raw_path
else:
path = os.fspath(arg)
try:
path = os.fspath(arg)
except TypeError:
path = arg
if not isinstance(path, str):
raise TypeError(
"argument should be a str or an os.PathLike "
Expand Down