[C++-sig] Re: test/embedding.cpp in bpl 1.31

David Abrahams dave at boost-consulting.com
Thu Aug 12 16:28:39 CEST 2004


David Abrahams <dave at boost-consulting.com> writes:

>> ok. May I suggest to add a little comment to avoid
>> confusing the reader
>
> OK.

Actually, I did the following.  The first use of extract<> was an
abuse.  Unfortunately, there are other extra pairs of parens required
to workaround gcc-2.95.3 parser bugs 

   object main_module(( ... ))
                      ^

But that is already repeated elsewhere in the file and didn't seem to
raise any alarms.

--- embedding.cpp.~1.10.~	2004-07-23 11:41:44.974043200 -0400
+++ embedding.cpp	2004-08-12 10:22:20.944963200 -0400
@@ -69,9 +69,8 @@
     Py_Initialize();
 
     // Retrieve the main module
-    python::object main_module = python::extract<python::object>(
-        PyImport_AddModule("__main__")
-    )();
+    python::object main_module((
+        python::handle<>(python::borrowed(PyImport_AddModule("__main__")))));
 
     // Retrieve the main module's namespace
     python::object main_namespace((main_module.attr("__dict__")));
@@ -106,7 +105,11 @@
     // But now creating and using instances of the Python class is almost
     // as easy!
     python::object py_base = PythonDerived();
-    Base& py = python::extract<Base&>(py_base)();
+    Base& py = python::extract<Base&>(py_base)
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
+        ()
+#endif 
+        ;
     std::cout << py.hello() << std::endl;
 }
 

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com




More information about the Cplusplus-sig mailing list