From 972974c0e3939a959c31926908264301845835db Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sun, 8 Jan 2006 07:08:21 +0000 Subject: fix to avoid copies when the wrapper class exists git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8293 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pycontainer.swg | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'Lib/python/pycontainer.swg') diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 3695998f6..06b76435c 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -717,10 +717,6 @@ namespace swig { return SWIG_OLDOBJ; } } - if (seq) { - PyErr_Format(PyExc_TypeError, "a %s is expected", - swig::type_name()); - } return SWIG_ERROR; } }; @@ -733,19 +729,23 @@ namespace swig { typedef typename sequence::const_iterator const_iterator; static PyObject *from(const sequence& seq) { - size_type size = seq.size(); - if (size <= (size_type)INT_MAX) { - PyObject *obj = PyTuple_New((int)size); - int i = 0; - for (const_iterator it = seq.begin(); - it != seq.end(); ++it, ++i) { - PyTuple_SetItem(obj,i,swig::from(*it)); - } - return obj; + swig_type_info *desc = swig::type_info(); + if (desc && desc->clientdata) { + return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN); } else { - PyErr_SetString(PyExc_OverflowError, - "sequence size not valid in python"); - return NULL; + size_type size = seq.size(); + if (size <= (size_type)INT_MAX) { + PyObject *obj = PyTuple_New((int)size); + int i = 0; + for (const_iterator it = seq.begin(); + it != seq.end(); ++it, ++i) { + PyTuple_SetItem(obj,i,swig::from(*it)); + } + return obj; + } else { + PyErr_SetString(PyExc_OverflowError,"sequence size not valid in python"); + return NULL; + } } } }; -- cgit v1.2.1