@@ -17,14 +17,15 @@ namespace python
1717object BOOST_PYTHON_DECL eval (str string, object global, object local)
1818{
1919 // Set suitable default values for global and local dicts.
20- if (!global)
20+ object none;
21+ if (global.ptr () == none.ptr ())
2122 {
2223 if (PyObject *g = PyEval_GetGlobals ())
2324 global = object (detail::borrowed_reference (g));
2425 else
2526 global = dict ();
2627 }
27- if (! local) local = global;
28+ if (local. ptr () == none. ptr () ) local = global;
2829 // should be 'char const *' but older python versions don't use 'const' yet.
2930 char *s = python::extract<char *>(string);
3031 PyObject* result = PyRun_String (s, Py_eval_input, global.ptr (), local.ptr ());
@@ -35,14 +36,15 @@ object BOOST_PYTHON_DECL eval(str string, object global, object local)
3536object BOOST_PYTHON_DECL exec (str string, object global, object local)
3637{
3738 // Set suitable default values for global and local dicts.
38- if (!global)
39+ object none;
40+ if (global.ptr () == none.ptr ())
3941 {
4042 if (PyObject *g = PyEval_GetGlobals ())
4143 global = object (detail::borrowed_reference (g));
4244 else
4345 global = dict ();
4446 }
45- if (! local) local = global;
47+ if (local. ptr () == none. ptr () ) local = global;
4648 // should be 'char const *' but older python versions don't use 'const' yet.
4749 char *s = python::extract<char *>(string);
4850 PyObject* result = PyRun_String (s, Py_file_input, global.ptr (), local.ptr ());
@@ -53,14 +55,15 @@ object BOOST_PYTHON_DECL exec(str string, object global, object local)
5355object BOOST_PYTHON_DECL exec_statement (str string, object global, object local)
5456{
5557 // Set suitable default values for global and local dicts.
56- if (!global)
58+ object none;
59+ if (global.ptr () == none.ptr ())
5760 {
5861 if (PyObject *g = PyEval_GetGlobals ())
5962 global = object (detail::borrowed_reference (g));
6063 else
6164 global = dict ();
6265 }
63- if (! local) local = global;
66+ if (local. ptr () == none. ptr () ) local = global;
6467 // should be 'char const *' but older python versions don't use 'const' yet.
6568 char *s = python::extract<char *>(string);
6669 PyObject* result = PyRun_String (s, Py_single_input, global.ptr (), local.ptr ());
@@ -74,14 +77,15 @@ object BOOST_PYTHON_DECL exec_statement(str string, object global, object local)
7477object BOOST_PYTHON_DECL exec_file (str filename, object global, object local)
7578{
7679 // Set suitable default values for global and local dicts.
77- if (!global)
80+ object none;
81+ if (global.ptr () == none.ptr ())
7882 {
7983 if (PyObject *g = PyEval_GetGlobals ())
8084 global = object (detail::borrowed_reference (g));
8185 else
8286 global = dict ();
8387 }
84- if (! local) local = global;
88+ if (local. ptr () == none. ptr () ) local = global;
8589 // should be 'char const *' but older python versions don't use 'const' yet.
8690 char *f = python::extract<char *>(filename);
8791 // Let python open the file to avoid potential binary incompatibilities.
0 commit comments