Debian Codegraph @

pypy/module/cpyext/include/_numpypy/numpy/npy_3kcompat.h

raw symbols SCIP
1 /*
2 * In numpy this is a convenience header file providing compatibility utilities
3 * for supporting Python 2 and Python 3 in the same code base.
4 *
5 * PyPy uses it as a convenient place to add compatability declarations
6 * It will be copied by numpy/core/setup.py by install_data to
7 * site-packages/numpy/core/includes/numpy
8 */
9
10 #ifndef _NPY_3KCOMPAT_H_
11 #define _NPY_3KCOMPAT_H_
12
13 #include "npy_common.h"
14
15 #define npy_PyFile_Dup(file, mode) (NULL)
16 #define npy_PyFile_DupClose(file, handle) (0)
17
18 static NPY_INLINE PyObject*
19 npy_PyFile_OpenFile(PyObject *filename, const char *mode)
20 {
21 PyObject *open;
22 open = PyDict_GetItemString(PyEval_GetBuiltins(), "open");
23 if (open == NULL) {
24 return NULL;
25 }
26 return PyObject_CallFunction(open, "Os", filename, mode);
27 }
28
29 static NPY_INLINE int
30 npy_PyFile_CloseFile(PyObject *file)
31 {
32 PyObject *ret;
33
34 ret = PyObject_CallMethod(file, "close", NULL);
35 if (ret == NULL) {
36 return -1;
37 }
38 Py_DECREF(ret);
39 return 0;
40 }
41 #endif