1
#ifndef _NPY_ARRAY_METHODS_H_
2
#define _NPY_ARRAY_METHODS_H_
3

4
#include "npy_import.h"
5

6
extern NPY_NO_EXPORT PyMethodDef array_methods[];
7

8

9
/*
10
 * Pathlib support, takes a borrowed reference and returns a new one.
11
 * The new object may be the same as the old.
12
 */
13
static inline PyObject *
14 1
NpyPath_PathlikeToFspath(PyObject *file)
15
{
16
    static PyObject *os_PathLike = NULL;
17
    static PyObject *os_fspath = NULL;
18 1
    npy_cache_import("numpy.compat", "os_PathLike", &os_PathLike);
19 1
    if (os_PathLike == NULL) {
20
        return NULL;
21
    }
22 1
    npy_cache_import("numpy.compat", "os_fspath", &os_fspath);
23 1
    if (os_fspath == NULL) {
24
        return NULL;
25
    }
26

27 1
    if (!PyObject_IsInstance(file, os_PathLike)) {
28 1
        Py_INCREF(file);
29 1
        return file;
30
    }
31 1
    return PyObject_CallFunctionObjArgs(os_fspath, file, NULL);
32
}
33

34
#endif

Read our documentation on viewing source code .

Loading