eval.h (11986:c12e4625ab56) eval.h (12037:d28054ac6ec9)
1/*
2 pybind11/exec.h: Support for evaluating Python expressions and statements
3 from strings and files
4
5 Copyright (c) 2016 Klemens Morgenstern <klemens.morgenstern@ed-chemnitz.de> and
6 Wenzel Jakob <wenzel.jakob@epfl.ch>
7
8 All rights reserved. Use of this source code is governed by a

--- 81 unchanged lines hidden (view full) ---

90 f = PyFile_AsFile(fobj.ptr());
91 closeFile = 0;
92#endif
93 if (!f) {
94 PyErr_Clear();
95 pybind11_fail("File \"" + fname_str + "\" could not be opened!");
96 }
97
1/*
2 pybind11/exec.h: Support for evaluating Python expressions and statements
3 from strings and files
4
5 Copyright (c) 2016 Klemens Morgenstern <klemens.morgenstern@ed-chemnitz.de> and
6 Wenzel Jakob <wenzel.jakob@epfl.ch>
7
8 All rights reserved. Use of this source code is governed by a

--- 81 unchanged lines hidden (view full) ---

90 f = PyFile_AsFile(fobj.ptr());
91 closeFile = 0;
92#endif
93 if (!f) {
94 PyErr_Clear();
95 pybind11_fail("File \"" + fname_str + "\" could not be opened!");
96 }
97
98#if PY_VERSION_HEX < 0x03000000 && defined(PYPY_VERSION)
99 PyObject *result = PyRun_File(f, fname_str.c_str(), start, global.ptr(),
100 local.ptr());
101 (void) closeFile;
102#else
98 PyObject *result = PyRun_FileEx(f, fname_str.c_str(), start, global.ptr(),
99 local.ptr(), closeFile);
103 PyObject *result = PyRun_FileEx(f, fname_str.c_str(), start, global.ptr(),
104 local.ptr(), closeFile);
105#endif
106
100 if (!result)
101 throw error_already_set();
102 return reinterpret_steal<object>(result);
103}
104
105NAMESPACE_END(pybind11)
107 if (!result)
108 throw error_already_set();
109 return reinterpret_steal<object>(result);
110}
111
112NAMESPACE_END(pybind11)