mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
gh-106046: Improve error message from os.fspath if __fspath__ is set to None (#106082)
This commit is contained in:
parent
8c24a83737
commit
93a970ffbc
5 changed files with 52 additions and 4 deletions
|
|
@ -1197,7 +1197,7 @@ path_converter(PyObject *o, void *p)
|
|||
PyObject *func, *res;
|
||||
|
||||
func = _PyObject_LookupSpecial(o, &_Py_ID(__fspath__));
|
||||
if (NULL == func) {
|
||||
if ((NULL == func) || (func == Py_None)) {
|
||||
goto error_format;
|
||||
}
|
||||
res = _PyObject_CallNoArgs(func);
|
||||
|
|
@ -15430,7 +15430,7 @@ PyOS_FSPath(PyObject *path)
|
|||
}
|
||||
|
||||
func = _PyObject_LookupSpecial(path, &_Py_ID(__fspath__));
|
||||
if (NULL == func) {
|
||||
if ((NULL == func) || (func == Py_None)) {
|
||||
return PyErr_Format(PyExc_TypeError,
|
||||
"expected str, bytes or os.PathLike object, "
|
||||
"not %.200s",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue