diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-06-25 23:06:12 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-25 23:06:12 (GMT) |
commit | 93a970ffbce58657cc99305be69e460a11371730 (patch) | |
tree | 599086f9f8f32527b67951ed6fbf3fe9a1e7457f /Lib/os.py | |
parent | 8c24a837371439b8e922ff47275085b581f510c5 (diff) | |
download | cpython-93a970ffbce58657cc99305be69e460a11371730.zip cpython-93a970ffbce58657cc99305be69e460a11371730.tar.gz cpython-93a970ffbce58657cc99305be69e460a11371730.tar.bz2 |
gh-106046: Improve error message from `os.fspath` if `__fspath__` is set to `None` (#106082)
Diffstat (limited to 'Lib/os.py')
-rw-r--r-- | Lib/os.py | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -1061,6 +1061,12 @@ def _fspath(path): else: raise TypeError("expected str, bytes or os.PathLike object, " "not " + path_type.__name__) + except TypeError: + if path_type.__fspath__ is None: + raise TypeError("expected str, bytes or os.PathLike object, " + "not " + path_type.__name__) from None + else: + raise if isinstance(path_repr, (str, bytes)): return path_repr else: |