| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 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 |