-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
posixmodule.c:path_converter() returns an invalid exception message for broken PathLike objects #80123
Comments
>>> class K:
... def __fspath__(self):
... return 1
...
>>> import os
>>> os.stat(K())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: stat: path should be string, bytes, os.PathLike or integer, not int This error message is internally inconsistent:
I would advise removing the custom >>>> class K:
.... def __fspath__(self):
.... return 1
....
>>>> import os
>>>> os.open(K(), os.O_RDONLY)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected K.__fspath__() to return str or bytes, not int |
The custom I agree that error reporting about incorrect type of the __fspath__() result should be improved. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: