2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-26 06:42:27 +00:00

Backport new eval() function from HEAD.

[SVN r37693]
This commit is contained in:
Stefan Seefeld
2007-05-15 13:43:52 +00:00
parent 13432b504f
commit b130c93af6
3 changed files with 27 additions and 3 deletions

View File

@@ -13,6 +13,15 @@ namespace boost
namespace python
{
object BOOST_PYTHON_DECL eval(str string, object global, object local)
{
// should be 'char const *' but older python versions don't use 'const' yet.
char *s = python::extract<char *>(string);
PyObject* result = PyRun_String(s, Py_eval_input, global.ptr(), local.ptr());
if (!result) throw_error_already_set();
return object(detail::new_reference(result));
}
object BOOST_PYTHON_DECL exec(str string, object global, object local)
{
// should be 'char const *' but older python versions don't use 'const' yet.