On 11/30/2011 12:38 PM, Josh Cherry wrote:

On Wed, 30 Nov 2011, Bob Hood wrote:

I'm probably doing something wrong, but given your example, it appears to work for me using SWIG 2.0.4 and Python 2.7.2 (debug build):
...
My interface file is:
%module (naturalvar="1") swigtest

%begin %{

#include <vector>
#include "test.h"
%}

%include    python.swg

%include    <typemaps.i>
%include    <std_vector.i>

%include "test.h"


%template(XVector) std::vector<X>;

%newobject GetXs;

Does this %newobject come too late to have an effect, replacing the original problem with a memory leak?

Yes, thanks.  That's what I was doing wrong.  :)


Render me gone,                       |||
Bob                                 ^(===)^
---------------------------------oOO--(_)--OOo---------------------------------
   "One of the penalties for refusing to participate in politics is that you
           end up being governed by your inferiors." -- Plato