diff options
author | Brett Cannon <brett@python.org> | 2016-07-15 17:41:49 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2016-07-15 17:41:49 (GMT) |
commit | 044283a426f1ffc09e4994b121ba588a46bf1318 (patch) | |
tree | 1909655750b03220cc7b456b080c25dbce6608b3 /Modules/posixmodule.c | |
parent | 1e6755ba43f873f9a67ffb254b06aec17a9c237e (diff) | |
download | cpython-044283a426f1ffc09e4994b121ba588a46bf1318.zip cpython-044283a426f1ffc09e4994b121ba588a46bf1318.tar.gz cpython-044283a426f1ffc09e4994b121ba588a46bf1318.tar.bz2 |
Issue #27512: Don't segfault when os.fspath() calls an object whose
__fspath__() raises an exception.
Thanks to Xiang Zhang for the patch.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 4c0f26e..7f16a83 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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, " |