On 07/13/2011 12:37 PM, Sebastian Ramacher wrote: > The attached patch fixes this bug. I've also submitted the patch upstream [3].
I've run svn diff in the wrong directory. Attached is an updated patch that applies cleanly to the current packaging of swig2.0. Kind regards, -- Sebastian Ramacher
Index: Lib/python/std_map.i =================================================================== --- Lib/python/std_map.i (revision 12755) +++ Lib/python/std_map.i (working copy) @@ -5,19 +5,19 @@ %fragment("StdMapTraits","header",fragment="StdSequenceTraits") { namespace swig { - template <class SwigPySeq, class K, class T > + template <class SwigPySeq, class K, class T, class C, class A> inline void - assign(const SwigPySeq& swigpyseq, std::map<K,T > *map) { - typedef typename std::map<K,T>::value_type value_type; + assign(const SwigPySeq& swigpyseq, std::map<K,T,C,A> *map) { + typedef typename std::map<K,T,C,A>::value_type value_type; typename SwigPySeq::const_iterator it = swigpyseq.begin(); for (;it != swigpyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } - template <class K, class T> - struct traits_asptr<std::map<K,T> > { - typedef std::map<K,T> map_type; + template <class K, class T, class C, class A> + struct traits_asptr<std::map<K,T,C,A> > { + typedef std::map<K,T,C,A> map_type; static int asptr(PyObject *obj, map_type **val) { int res = SWIG_ERROR; SWIG_PYTHON_THREAD_BEGIN_BLOCK; @@ -27,7 +27,7 @@ /* In Python 3.x the ".items()" method returns a dict_items object */ items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif - res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val); + res = traits_asptr_stdseq<std::map<K,T,C,A>, std::pair<K, T> >::asptr(items, val); } else { map_type *p; res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0); @@ -38,9 +38,9 @@ } }; - template <class K, class T > - struct traits_from<std::map<K,T> > { - typedef std::map<K,T> map_type; + template <class K, class T, class C, class A> + struct traits_from<std::map<K,T,C,A> > { + typedef std::map<K,T,C,A> map_type; typedef typename map_type::const_iterator const_iterator; typedef typename map_type::size_type size_type;
signature.asc
Description: OpenPGP digital signature