summaryrefslogtreecommitdiff
path: root/numpy/core/src/multiarray/methods.h
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/src/multiarray/methods.h')
-rw-r--r--numpy/core/src/multiarray/methods.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/methods.h b/numpy/core/src/multiarray/methods.h
index b96a3c8a8..7a9a24a00 100644
--- a/numpy/core/src/multiarray/methods.h
+++ b/numpy/core/src/multiarray/methods.h
@@ -8,7 +8,10 @@ extern NPY_NO_EXPORT PyMethodDef array_methods[];
NPY_NO_EXPORT const char *
npy_casting_to_string(NPY_CASTING casting);
-/* Pathlib support */
+/*
+ * Pathlib support, takes a borrowed reference and returns a new one.
+ * The new object may be the same as the old.
+ */
static inline PyObject *
NpyPath_PathlikeToFspath(PyObject *file)
{
@@ -24,6 +27,7 @@ NpyPath_PathlikeToFspath(PyObject *file)
}
if (!PyObject_IsInstance(file, os_PathLike)) {
+ Py_INCREF(file);
return file;
}
return PyObject_CallFunctionObjArgs(os_fspath, file, NULL);