summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2016-06-10 21:37:21 (GMT)
committerBrett Cannon <brett@python.org>2016-06-10 21:37:21 (GMT)
commit96881cd6218000380d4a6ce60ff47bb6d785e524 (patch)
tree2e60afb93e6419a6d8d3a84d701c27d7364eaaeb /Modules/posixmodule.c
parent419e8ede1954461f45ee93629d6252d81919cbfe (diff)
downloadcpython-96881cd6218000380d4a6ce60ff47bb6d785e524.zip
cpython-96881cd6218000380d4a6ce60ff47bb6d785e524.tar.gz
cpython-96881cd6218000380d4a6ce60ff47bb6d785e524.tar.bz2
Issue #27186: Add os.PathLike support to DirEntry
Initial patch thanks to Jelle Zijlstra.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index f4510db..ecdeab4 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -11718,6 +11718,13 @@ DirEntry_repr(DirEntry *self)
return PyUnicode_FromFormat("<DirEntry %R>", self->name);
}
+static PyObject *
+DirEntry_fspath(DirEntry *self)
+{
+ Py_INCREF(self->path);
+ return self->path;
+}
+
static PyMemberDef DirEntry_members[] = {
{"name", T_OBJECT_EX, offsetof(DirEntry, name), READONLY,
"the entry's base filename, relative to scandir() \"path\" argument"},
@@ -11742,6 +11749,9 @@ static PyMethodDef DirEntry_methods[] = {
{"inode", (PyCFunction)DirEntry_inode, METH_NOARGS,
"return inode of the entry; cached per entry",
},
+ {"__fspath__", (PyCFunction)DirEntry_fspath, METH_NOARGS,
+ "returns the path for the entry",
+ },
{NULL}
};