gh-106046: Improve error message from os.fspath if __fspath__ is set to None (#106082)

This commit is contained in:
Alex Waygood 2023-06-26 00:06:12 +01:00 committed by GitHub
parent 8c24a83737
commit 93a970ffbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 4 deletions

View file

@ -3179,8 +3179,9 @@ An example of an asynchronous context manager class::
lead to some very strange behaviour if it is handled incorrectly.
.. [#] The :meth:`~object.__hash__`, :meth:`~object.__iter__`,
:meth:`~object.__reversed__`, and :meth:`~object.__contains__` methods have
special handling for this; others
:meth:`~object.__reversed__`, :meth:`~object.__contains__`,
:meth:`~object.__class_getitem__` and :meth:`~os.PathLike.__fspath__`
methods have special handling for this. Others
will still raise a :exc:`TypeError`, but may do so by relying on
the behavior that ``None`` is not callable.