[C++-sig] How to deep-copy and delete a mixed python/C++ object from C++

David Abrahams dave at boost-consulting.com
Fri Mar 31 22:19:45 CEST 2006


"Paul F. Kunz" <Paul_Kunz at slac.stanford.edu> writes:

>    I'm not sure about deletion, but here is how I do the copying (with
> a lot of help from Dave Abrahams)...
>
>
> http://www.slac.stanford.edu/grp/ek/hippodraw/lib/FunctionWrap_8cxx-source.html#l00179

How can this possibly work?

00177 FunctionBase *
00178 FunctionWrap::
00179 clone () const
00180 {
00181 #ifndef HAVE_OLD_PYTHON
00182   PyGILState_STATE state = PyGILState_Ensure ();
00183 
00184   object py_result;

py_result is now None

00185 
00186   if (override clone = this->get_override("clone")) {
00187      try {
00188         // The Python class author overrode clone; do
00189         // whatever she says
00190         py_result ( clone() );

Attempts to invoke None like a function on the result of calling
clone()

??

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list