mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
Issue #27512: Don't segfault when os.fspath() calls an object whose
__fspath__() raises an exception. Thanks to Xiang Zhang for the patch.
This commit is contained in:
parent
1e6755ba43
commit
044283a426
3 changed files with 23 additions and 6 deletions
|
|
@ -12319,6 +12319,10 @@ PyOS_FSPath(PyObject *path)
|
|||
|
||||
path_repr = PyObject_CallFunctionObjArgs(func, NULL);
|
||||
Py_DECREF(func);
|
||||
if (NULL == path_repr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(PyUnicode_Check(path_repr) || PyBytes_Check(path_repr))) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"expected %.200s.__fspath__() to return str or bytes, "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue