]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/python/src/exec.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / python / src / exec.cpp
index fa2860e40e3d3ea06deb71e54c642282a7ea53a1..171c6f4189b9cf051d1f13954d4143113a63a4d4 100644 (file)
@@ -15,6 +15,11 @@ namespace python
 {
 
 object BOOST_PYTHON_DECL eval(str string, object global, object local)
+{
+    return eval(python::extract<char const *>(string), global, local);
+}
+
+object BOOST_PYTHON_DECL eval(char const *string, object global, object local)
 {
   // Set suitable default values for global and local dicts.
   if (global.is_none())
@@ -26,13 +31,18 @@ object BOOST_PYTHON_DECL eval(str string, object global, object local)
   }
   if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
-  char *s = python::extract<char *>(string);
+  char *s = const_cast<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)
+{
+    return exec(python::extract<char const *>(string), global, local);
+}
+
+object BOOST_PYTHON_DECL exec(char const *string, object global, object local)
 {
   // Set suitable default values for global and local dicts.
   if (global.is_none())
@@ -44,13 +54,18 @@ object BOOST_PYTHON_DECL exec(str string, object global, object local)
   }
   if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
-  char *s = python::extract<char *>(string);
+  char *s = const_cast<char *>(string);
   PyObject* result = PyRun_String(s, Py_file_input, global.ptr(), local.ptr());
   if (!result) throw_error_already_set();
   return object(detail::new_reference(result));
 }
 
 object BOOST_PYTHON_DECL exec_statement(str string, object global, object local)
+{
+    return exec_statement(python::extract<char const *>(string), global, local);
+}
+
+object BOOST_PYTHON_DECL exec_statement(char const *string, object global, object local)
 {
   // Set suitable default values for global and local dicts.
   if (global.is_none())
@@ -62,7 +77,7 @@ object BOOST_PYTHON_DECL exec_statement(str string, object global, object local)
   }
   if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
-  char *s = python::extract<char *>(string);
+  char *s = const_cast<char *>(string);
   PyObject* result = PyRun_String(s, Py_single_input, global.ptr(), local.ptr());
   if (!result) throw_error_already_set();
   return object(detail::new_reference(result));
@@ -72,6 +87,11 @@ object BOOST_PYTHON_DECL exec_statement(str string, object global, object local)
 // global and local are the global and local scopes respectively,
 // used during execution.
 object BOOST_PYTHON_DECL exec_file(str filename, object global, object local)
+{
+    return exec_file(python::extract<char const *>(filename), global, local);
+}
+
+object BOOST_PYTHON_DECL exec_file(char const *filename, object global, object local)
 {
   // Set suitable default values for global and local dicts.
   if (global.is_none())
@@ -83,7 +103,7 @@ object BOOST_PYTHON_DECL exec_file(str filename, object global, object local)
   }
   if (local.is_none()) local = global;
   // should be 'char const *' but older python versions don't use 'const' yet.
-  char *f = python::extract<char *>(filename);
+  char *f = const_cast<char *>(filename);
   // Let python open the file to avoid potential binary incompatibilities.
 #if PY_VERSION_HEX >= 0x03040000
   FILE *fs = _Py_fopen(f, "r");