summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2016-07-15 17:41:49 (GMT)
committerBrett Cannon <brett@python.org>2016-07-15 17:41:49 (GMT)
commit044283a426f1ffc09e4994b121ba588a46bf1318 (patch)
tree1909655750b03220cc7b456b080c25dbce6608b3 /Modules
parent1e6755ba43f873f9a67ffb254b06aec17a9c237e (diff)
downloadcpython-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')
-rw-r--r--Modules/posixmodule.c4
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, "