MCPcopy Create free account
hub / github.com/numpy/numpy / NpyPath_PathlikeToFspath

Function NpyPath_PathlikeToFspath

numpy/core/src/multiarray/methods.h:13–32  ·  view source on GitHub ↗

* Pathlib support, takes a borrowed reference and returns a new one. * The new object may be the same as the old. */

Source from the content-addressed store, hash-verified

11 * The new object may be the same as the old.
12 */
13static inline PyObject *
14NpyPath_PathlikeToFspath(PyObject *file)
15{
16 static PyObject *os_PathLike = NULL;
17 static PyObject *os_fspath = NULL;
18 npy_cache_import("numpy.compat", "os_PathLike", &os_PathLike);
19 if (os_PathLike == NULL) {
20 return NULL;
21 }
22 npy_cache_import("numpy.compat", "os_fspath", &os_fspath);
23 if (os_fspath == NULL) {
24 return NULL;
25 }
26
27 if (!PyObject_IsInstance(file, os_PathLike)) {
28 Py_INCREF(file);
29 return file;
30 }
31 return PyObject_CallFunctionObjArgs(os_fspath, file, NULL);
32}
33
34#endif /* NUMPY_CORE_SRC_MULTIARRAY_METHODS_H_ */

Callers 2

array_tofileFunction · 0.85
array_fromfileFunction · 0.85

Calls 1

npy_cache_importFunction · 0.85

Tested by

no test coverage detected