[Scipy-svn] r7071 - trunk/scipy/sparse/sparsetools

scipy-svn at scipy.org scipy-svn at scipy.org
Sat Jan 22 17:07:42 EST 2011


Author: ptvirtan
Date: 2011-01-22 16:07:40 -0600 (Sat, 22 Jan 2011)
New Revision: 7071

Modified:
   trunk/scipy/sparse/sparsetools/README.txt
   trunk/scipy/sparse/sparsetools/bsr.py
   trunk/scipy/sparse/sparsetools/bsr_wrap.cxx
   trunk/scipy/sparse/sparsetools/coo.py
   trunk/scipy/sparse/sparsetools/coo_wrap.cxx
   trunk/scipy/sparse/sparsetools/csc.py
   trunk/scipy/sparse/sparsetools/csc_wrap.cxx
   trunk/scipy/sparse/sparsetools/csgraph.py
   trunk/scipy/sparse/sparsetools/csgraph_wrap.cxx
   trunk/scipy/sparse/sparsetools/csr.py
   trunk/scipy/sparse/sparsetools/csr_wrap.cxx
   trunk/scipy/sparse/sparsetools/dia.py
   trunk/scipy/sparse/sparsetools/dia_wrap.cxx
Log:
GEN: sparse: re-swig sparsetools with swig 2.0.1 + PyCapsule hack

The files were swig-ed with Swig 2.0.1 with the patch from
http://sourceforge.net/tracker/?func=detail&aid=3047039&group_id=1645&atid=301645

Modified: trunk/scipy/sparse/sparsetools/README.txt
===================================================================
--- trunk/scipy/sparse/sparsetools/README.txt	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/README.txt	2011-01-22 22:07:40 UTC (rev 7071)
@@ -8,5 +8,4 @@
    swig -c++ -python coo.i
    swig -c++ -python dia.i
    swig -c++ -python bsr.i
-
-
+   swig -c++ -python csgraph.i

Modified: trunk/scipy/sparse/sparsetools/bsr.py
===================================================================
--- trunk/scipy/sparse/sparsetools/bsr.py	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/bsr.py	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.40
+# Version 2.0.1+capsulehack
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.

Modified: trunk/scipy/sparse/sparsetools/bsr_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/bsr_wrap.cxx	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/bsr_wrap.cxx	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.40
+ * Version 2.0.1+capsulehack
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -201,7 +201,7 @@
 /* 
    Flags/methods for returning states.
    
-   The SWIG conversion methods, as ConvertPtr, return and integer 
+   The SWIG conversion methods, as ConvertPtr, return an integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
@@ -1088,9 +1088,6 @@
 
 
 /* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
  * pyrun.swg
  *
  * This file contains the runtime support for Python modules
@@ -1137,8 +1134,18 @@
 #define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
 #define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
 #define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
-#define SWIG_fail                        		goto fail					   
+#define SWIG_fail                        		goto fail				
 
+/*
+ * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
+ * CObjects API.
+ */
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
+#define USE_CAPSULES
+#define TYPE_POINTER_NAME \
+    ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
 
 /* Runtime API implementation */
 
@@ -2071,10 +2078,13 @@
     return SWIG_Python_str_FromChar("this");
 }
 
+static PyObject *swig_this = NULL;
+
 SWIGRUNTIME PyObject *
 SWIG_This(void)
 {
-  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+  if (swig_this == NULL)
+    swig_this = _SWIG_This();
   return swig_this;
 }
 
@@ -2178,7 +2188,7 @@
               int newmemory = 0;
               *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
               if (newmemory == SWIG_CAST_NEW_MEMORY) {
-                assert(own);
+                assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
                 if (own)
                   *own = *own | SWIG_CAST_NEW_MEMORY;
               }
@@ -2448,8 +2458,12 @@
 #ifdef SWIG_LINK_RUNTIME
     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 #else
+#ifdef USE_CAPSULES
+    type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
+#else
     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+#endif
     if (PyErr_Occurred()) {
       PyErr_Clear();
       type_pointer = (void *)0;
@@ -2494,9 +2508,14 @@
 SWIGRUNTIME void
 SWIG_Python_DestroyModule(void *vptr)
 {
+  size_t i;
+#ifdef USE_CAPSULES
+  swig_module_info *swig_module =
+    (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
+#else
   swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
   swig_type_info **types = swig_module->types;
-  size_t i;
   for (i =0; i < swig_module->size; ++i) {
     swig_type_info *ty = types[i];
     if (ty->owndata) {
@@ -2505,6 +2524,7 @@
     }
   }
   Py_DECREF(SWIG_This());
+  swig_this = NULL;
 }
 
 SWIGRUNTIME void
@@ -2518,9 +2538,18 @@
   PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				   swig_empty_runtime_method_table);
 #endif
+#ifdef USE_CAPSULES
+  PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
+				    (PyCapsule_Destructor)SWIG_Python_DestroyModule);
+#else
   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+#endif
   if (pointer && module) {
+#ifdef USE_CAPSULES
+    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+#else
     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+#endif
   } else {
     Py_XDECREF(pointer);
   }
@@ -2541,12 +2570,20 @@
   PyObject *obj = PyDict_GetItem(cache, key);
   swig_type_info *descriptor;
   if (obj) {
+#ifdef USE_CAPSULES
+    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
+#else
     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
   } else {
     swig_module_info *swig_module = SWIG_Python_GetModule();
     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
     if (descriptor) {
+#ifdef USE_CAPSULES
+      obj = PyCapsule_New(descriptor, type, NULL);
+#else
       obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
       PyDict_SetItem(cache, key, obj);
       Py_DECREF(obj);
     }
@@ -2708,7 +2745,7 @@
 #endif
 #define SWIG_name    "_bsr"
 
-#define SWIGVERSION 0x010340 
+#define SWIGVERSION 0x020001 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -5763,7 +5800,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_diagonal'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_diagonal'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_diagonal< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],signed char [])\n"
     "    bsr_diagonal< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char [])\n"
@@ -8259,7 +8296,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_scale_rows'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_scale_rows'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_scale_rows< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char [],signed char const [])\n"
     "    bsr_scale_rows< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char [],unsigned char const [])\n"
@@ -10755,7 +10792,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_scale_columns'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_scale_columns'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_scale_columns< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char [],signed char const [])\n"
     "    bsr_scale_columns< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char [],unsigned char const [])\n"
@@ -13615,7 +13652,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_transpose'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_transpose'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_transpose< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    bsr_transpose< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -17903,7 +17940,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_matmat_pass2'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_matmat_pass2'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_matmat_pass2< int,signed char >(int const,int const,int const,int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    bsr_matmat_pass2< int,unsigned char >(int const,int const,int const,int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -20805,7 +20842,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_matvec'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_matvec'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_matvec< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n"
     "    bsr_matvec< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -23917,7 +23954,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_matvecs'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_matvecs'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_matvecs< int,signed char >(int const,int const,int const,int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n"
     "    bsr_matvecs< int,unsigned char >(int const,int const,int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -27995,7 +28032,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_elmul_bsr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_elmul_bsr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_elmul_bsr< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    bsr_elmul_bsr< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -32073,7 +32110,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_eldiv_bsr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_eldiv_bsr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_eldiv_bsr< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    bsr_eldiv_bsr< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -36151,7 +36188,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_plus_bsr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_plus_bsr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_plus_bsr< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    bsr_plus_bsr< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -40229,7 +40266,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_minus_bsr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_minus_bsr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_minus_bsr< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    bsr_minus_bsr< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -41871,7 +41908,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'bsr_sort_indices'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'bsr_sort_indices'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    bsr_sort_indices< int,signed char >(int const,int const,int const,int const,int [],int [],signed char [])\n"
     "    bsr_sort_indices< int,unsigned char >(int const,int const,int const,int const,int [],int [],unsigned char [])\n"
@@ -42878,15 +42915,15 @@
           }
         }
         if (ci) {
-          size_t shift = (ci->ptype) - types;
-          swig_type_info *ty = types_initial[shift];
-          size_t ldoc = (c - methods[i].ml_doc);
-          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-          char *ndoc = (char*)malloc(ldoc + lptr + 10);
-          if (ndoc) {
-            char *buff = ndoc;
-            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-            if (ptr) {
+          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+          if (ptr) {
+            size_t shift = (ci->ptype) - types;
+            swig_type_info *ty = types_initial[shift];
+            size_t ldoc = (c - methods[i].ml_doc);
+            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+            char *ndoc = (char*)malloc(ldoc + lptr + 10);
+            if (ndoc) {
+              char *buff = ndoc;
               strncpy(buff, methods[i].ml_doc, ldoc);
               buff += ldoc;
               strncpy(buff, "swig_ptr: ", 10);

Modified: trunk/scipy/sparse/sparsetools/coo.py
===================================================================
--- trunk/scipy/sparse/sparsetools/coo.py	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/coo.py	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.40
+# Version 2.0.1+capsulehack
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.

Modified: trunk/scipy/sparse/sparsetools/coo_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/coo_wrap.cxx	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/coo_wrap.cxx	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.40
+ * Version 2.0.1+capsulehack
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -201,7 +201,7 @@
 /* 
    Flags/methods for returning states.
    
-   The SWIG conversion methods, as ConvertPtr, return and integer 
+   The SWIG conversion methods, as ConvertPtr, return an integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
@@ -1088,9 +1088,6 @@
 
 
 /* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
  * pyrun.swg
  *
  * This file contains the runtime support for Python modules
@@ -1137,8 +1134,18 @@
 #define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
 #define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
 #define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
-#define SWIG_fail                        		goto fail					   
+#define SWIG_fail                        		goto fail				
 
+/*
+ * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
+ * CObjects API.
+ */
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
+#define USE_CAPSULES
+#define TYPE_POINTER_NAME \
+    ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
 
 /* Runtime API implementation */
 
@@ -2071,10 +2078,13 @@
     return SWIG_Python_str_FromChar("this");
 }
 
+static PyObject *swig_this = NULL;
+
 SWIGRUNTIME PyObject *
 SWIG_This(void)
 {
-  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+  if (swig_this == NULL)
+    swig_this = _SWIG_This();
   return swig_this;
 }
 
@@ -2178,7 +2188,7 @@
               int newmemory = 0;
               *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
               if (newmemory == SWIG_CAST_NEW_MEMORY) {
-                assert(own);
+                assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
                 if (own)
                   *own = *own | SWIG_CAST_NEW_MEMORY;
               }
@@ -2448,8 +2458,12 @@
 #ifdef SWIG_LINK_RUNTIME
     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 #else
+#ifdef USE_CAPSULES
+    type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
+#else
     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+#endif
     if (PyErr_Occurred()) {
       PyErr_Clear();
       type_pointer = (void *)0;
@@ -2494,9 +2508,14 @@
 SWIGRUNTIME void
 SWIG_Python_DestroyModule(void *vptr)
 {
+  size_t i;
+#ifdef USE_CAPSULES
+  swig_module_info *swig_module =
+    (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
+#else
   swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
   swig_type_info **types = swig_module->types;
-  size_t i;
   for (i =0; i < swig_module->size; ++i) {
     swig_type_info *ty = types[i];
     if (ty->owndata) {
@@ -2505,6 +2524,7 @@
     }
   }
   Py_DECREF(SWIG_This());
+  swig_this = NULL;
 }
 
 SWIGRUNTIME void
@@ -2518,9 +2538,18 @@
   PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				   swig_empty_runtime_method_table);
 #endif
+#ifdef USE_CAPSULES
+  PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
+				    (PyCapsule_Destructor)SWIG_Python_DestroyModule);
+#else
   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+#endif
   if (pointer && module) {
+#ifdef USE_CAPSULES
+    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+#else
     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+#endif
   } else {
     Py_XDECREF(pointer);
   }
@@ -2541,12 +2570,20 @@
   PyObject *obj = PyDict_GetItem(cache, key);
   swig_type_info *descriptor;
   if (obj) {
+#ifdef USE_CAPSULES
+    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
+#else
     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
   } else {
     swig_module_info *swig_module = SWIG_Python_GetModule();
     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
     if (descriptor) {
+#ifdef USE_CAPSULES
+      obj = PyCapsule_New(descriptor, type, NULL);
+#else
       obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
       PyDict_SetItem(cache, key, obj);
       Py_DECREF(obj);
     }
@@ -2708,7 +2745,7 @@
 #endif
 #define SWIG_name    "_coo"
 
-#define SWIGVERSION 0x010340 
+#define SWIGVERSION 0x020001 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -5927,7 +5964,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'coo_tocsr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'coo_tocsr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    coo_tocsr< int,signed char >(int const,int const,int const,int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    coo_tocsr< int,unsigned char >(int const,int const,int const,int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -8577,7 +8614,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'coo_tocsc'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'coo_tocsc'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    coo_tocsc< int,signed char >(int const,int const,int const,int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    coo_tocsc< int,unsigned char >(int const,int const,int const,int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -10863,7 +10900,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'coo_todense'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'coo_todense'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    coo_todense< int,signed char >(int const,int const,int const,int const [],int const [],signed char const [],signed char [])\n"
     "    coo_todense< int,unsigned char >(int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char [])\n"
@@ -13135,7 +13172,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'coo_matvec'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'coo_matvec'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    coo_matvec< int,signed char >(int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n"
     "    coo_matvec< int,unsigned char >(int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -13883,15 +13920,15 @@
           }
         }
         if (ci) {
-          size_t shift = (ci->ptype) - types;
-          swig_type_info *ty = types_initial[shift];
-          size_t ldoc = (c - methods[i].ml_doc);
-          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-          char *ndoc = (char*)malloc(ldoc + lptr + 10);
-          if (ndoc) {
-            char *buff = ndoc;
-            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-            if (ptr) {
+          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+          if (ptr) {
+            size_t shift = (ci->ptype) - types;
+            swig_type_info *ty = types_initial[shift];
+            size_t ldoc = (c - methods[i].ml_doc);
+            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+            char *ndoc = (char*)malloc(ldoc + lptr + 10);
+            if (ndoc) {
+              char *buff = ndoc;
               strncpy(buff, methods[i].ml_doc, ldoc);
               buff += ldoc;
               strncpy(buff, "swig_ptr: ", 10);

Modified: trunk/scipy/sparse/sparsetools/csc.py
===================================================================
--- trunk/scipy/sparse/sparsetools/csc.py	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/csc.py	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.40
+# Version 2.0.1+capsulehack
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.

Modified: trunk/scipy/sparse/sparsetools/csc_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/csc_wrap.cxx	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/csc_wrap.cxx	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.40
+ * Version 2.0.1+capsulehack
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -201,7 +201,7 @@
 /* 
    Flags/methods for returning states.
    
-   The SWIG conversion methods, as ConvertPtr, return and integer 
+   The SWIG conversion methods, as ConvertPtr, return an integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
@@ -1088,9 +1088,6 @@
 
 
 /* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
  * pyrun.swg
  *
  * This file contains the runtime support for Python modules
@@ -1137,8 +1134,18 @@
 #define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
 #define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
 #define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
-#define SWIG_fail                        		goto fail					   
+#define SWIG_fail                        		goto fail				
 
+/*
+ * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
+ * CObjects API.
+ */
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
+#define USE_CAPSULES
+#define TYPE_POINTER_NAME \
+    ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
 
 /* Runtime API implementation */
 
@@ -2071,10 +2078,13 @@
     return SWIG_Python_str_FromChar("this");
 }
 
+static PyObject *swig_this = NULL;
+
 SWIGRUNTIME PyObject *
 SWIG_This(void)
 {
-  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+  if (swig_this == NULL)
+    swig_this = _SWIG_This();
   return swig_this;
 }
 
@@ -2178,7 +2188,7 @@
               int newmemory = 0;
               *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
               if (newmemory == SWIG_CAST_NEW_MEMORY) {
-                assert(own);
+                assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
                 if (own)
                   *own = *own | SWIG_CAST_NEW_MEMORY;
               }
@@ -2448,8 +2458,12 @@
 #ifdef SWIG_LINK_RUNTIME
     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 #else
+#ifdef USE_CAPSULES
+    type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
+#else
     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+#endif
     if (PyErr_Occurred()) {
       PyErr_Clear();
       type_pointer = (void *)0;
@@ -2494,9 +2508,14 @@
 SWIGRUNTIME void
 SWIG_Python_DestroyModule(void *vptr)
 {
+  size_t i;
+#ifdef USE_CAPSULES
+  swig_module_info *swig_module =
+    (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
+#else
   swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
   swig_type_info **types = swig_module->types;
-  size_t i;
   for (i =0; i < swig_module->size; ++i) {
     swig_type_info *ty = types[i];
     if (ty->owndata) {
@@ -2505,6 +2524,7 @@
     }
   }
   Py_DECREF(SWIG_This());
+  swig_this = NULL;
 }
 
 SWIGRUNTIME void
@@ -2518,9 +2538,18 @@
   PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				   swig_empty_runtime_method_table);
 #endif
+#ifdef USE_CAPSULES
+  PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
+				    (PyCapsule_Destructor)SWIG_Python_DestroyModule);
+#else
   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+#endif
   if (pointer && module) {
+#ifdef USE_CAPSULES
+    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+#else
     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+#endif
   } else {
     Py_XDECREF(pointer);
   }
@@ -2541,12 +2570,20 @@
   PyObject *obj = PyDict_GetItem(cache, key);
   swig_type_info *descriptor;
   if (obj) {
+#ifdef USE_CAPSULES
+    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
+#else
     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
   } else {
     swig_module_info *swig_module = SWIG_Python_GetModule();
     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
     if (descriptor) {
+#ifdef USE_CAPSULES
+      obj = PyCapsule_New(descriptor, type, NULL);
+#else
       obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
       PyDict_SetItem(cache, key, obj);
       Py_DECREF(obj);
     }
@@ -2708,7 +2745,7 @@
 #endif
 #define SWIG_name    "_csc"
 
-#define SWIGVERSION 0x010340 
+#define SWIGVERSION 0x020001 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -5477,7 +5514,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_diagonal'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_diagonal'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_diagonal< int,signed char >(int const,int const,int const [],int const [],signed char const [],signed char [])\n"
     "    csc_diagonal< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],unsigned char [])\n"
@@ -7917,7 +7954,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_tocsr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_tocsr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_tocsr< int,signed char >(int const,int const,int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csc_tocsr< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -11575,7 +11612,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_matmat_pass2'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_matmat_pass2'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_matmat_pass2< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csc_matmat_pass2< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -14057,7 +14094,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_matvec'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_matvec'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_matvec< int,signed char >(int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n"
     "    csc_matvec< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -16749,7 +16786,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_matvecs'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_matvecs'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_matvecs< int,signed char >(int const,int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n"
     "    csc_matvecs< int,unsigned char >(int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -20407,7 +20444,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_elmul_csc'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_elmul_csc'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_elmul_csc< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csc_elmul_csc< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -24065,7 +24102,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_eldiv_csc'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_eldiv_csc'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_eldiv_csc< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csc_eldiv_csc< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -27723,7 +27760,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_plus_csc'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_plus_csc'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_plus_csc< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csc_plus_csc< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -31381,7 +31418,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csc_minus_csc'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csc_minus_csc'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csc_minus_csc< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csc_minus_csc< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -32266,15 +32303,15 @@
           }
         }
         if (ci) {
-          size_t shift = (ci->ptype) - types;
-          swig_type_info *ty = types_initial[shift];
-          size_t ldoc = (c - methods[i].ml_doc);
-          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-          char *ndoc = (char*)malloc(ldoc + lptr + 10);
-          if (ndoc) {
-            char *buff = ndoc;
-            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-            if (ptr) {
+          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+          if (ptr) {
+            size_t shift = (ci->ptype) - types;
+            swig_type_info *ty = types_initial[shift];
+            size_t ldoc = (c - methods[i].ml_doc);
+            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+            char *ndoc = (char*)malloc(ldoc + lptr + 10);
+            if (ndoc) {
+              char *buff = ndoc;
               strncpy(buff, methods[i].ml_doc, ldoc);
               buff += ldoc;
               strncpy(buff, "swig_ptr: ", 10);

Modified: trunk/scipy/sparse/sparsetools/csgraph.py
===================================================================
--- trunk/scipy/sparse/sparsetools/csgraph.py	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/csgraph.py	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.40
+# Version 2.0.1+capsulehack
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.

Modified: trunk/scipy/sparse/sparsetools/csgraph_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/csgraph_wrap.cxx	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/csgraph_wrap.cxx	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.40
+ * Version 2.0.1+capsulehack
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -201,7 +201,7 @@
 /* 
    Flags/methods for returning states.
    
-   The SWIG conversion methods, as ConvertPtr, return and integer 
+   The SWIG conversion methods, as ConvertPtr, return an integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
@@ -1088,9 +1088,6 @@
 
 
 /* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
  * pyrun.swg
  *
  * This file contains the runtime support for Python modules
@@ -1137,8 +1134,18 @@
 #define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
 #define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
 #define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
-#define SWIG_fail                        		goto fail					   
+#define SWIG_fail                        		goto fail				
 
+/*
+ * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
+ * CObjects API.
+ */
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
+#define USE_CAPSULES
+#define TYPE_POINTER_NAME \
+    ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
 
 /* Runtime API implementation */
 
@@ -2071,10 +2078,13 @@
     return SWIG_Python_str_FromChar("this");
 }
 
+static PyObject *swig_this = NULL;
+
 SWIGRUNTIME PyObject *
 SWIG_This(void)
 {
-  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+  if (swig_this == NULL)
+    swig_this = _SWIG_This();
   return swig_this;
 }
 
@@ -2178,7 +2188,7 @@
               int newmemory = 0;
               *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
               if (newmemory == SWIG_CAST_NEW_MEMORY) {
-                assert(own);
+                assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
                 if (own)
                   *own = *own | SWIG_CAST_NEW_MEMORY;
               }
@@ -2448,8 +2458,12 @@
 #ifdef SWIG_LINK_RUNTIME
     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 #else
+#ifdef USE_CAPSULES
+    type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
+#else
     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+#endif
     if (PyErr_Occurred()) {
       PyErr_Clear();
       type_pointer = (void *)0;
@@ -2494,9 +2508,14 @@
 SWIGRUNTIME void
 SWIG_Python_DestroyModule(void *vptr)
 {
+  size_t i;
+#ifdef USE_CAPSULES
+  swig_module_info *swig_module =
+    (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
+#else
   swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
   swig_type_info **types = swig_module->types;
-  size_t i;
   for (i =0; i < swig_module->size; ++i) {
     swig_type_info *ty = types[i];
     if (ty->owndata) {
@@ -2505,6 +2524,7 @@
     }
   }
   Py_DECREF(SWIG_This());
+  swig_this = NULL;
 }
 
 SWIGRUNTIME void
@@ -2518,9 +2538,18 @@
   PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				   swig_empty_runtime_method_table);
 #endif
+#ifdef USE_CAPSULES
+  PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
+				    (PyCapsule_Destructor)SWIG_Python_DestroyModule);
+#else
   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+#endif
   if (pointer && module) {
+#ifdef USE_CAPSULES
+    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+#else
     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+#endif
   } else {
     Py_XDECREF(pointer);
   }
@@ -2541,12 +2570,20 @@
   PyObject *obj = PyDict_GetItem(cache, key);
   swig_type_info *descriptor;
   if (obj) {
+#ifdef USE_CAPSULES
+    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
+#else
     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
   } else {
     swig_module_info *swig_module = SWIG_Python_GetModule();
     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
     if (descriptor) {
+#ifdef USE_CAPSULES
+      obj = PyCapsule_New(descriptor, type, NULL);
+#else
       obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
       PyDict_SetItem(cache, key, obj);
       Py_DECREF(obj);
     }
@@ -2708,7 +2745,7 @@
 #endif
 #define SWIG_name    "_csgraph"
 
-#define SWIGVERSION 0x010340 
+#define SWIGVERSION 0x020001 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -3920,15 +3957,15 @@
           }
         }
         if (ci) {
-          size_t shift = (ci->ptype) - types;
-          swig_type_info *ty = types_initial[shift];
-          size_t ldoc = (c - methods[i].ml_doc);
-          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-          char *ndoc = (char*)malloc(ldoc + lptr + 10);
-          if (ndoc) {
-            char *buff = ndoc;
-            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-            if (ptr) {
+          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+          if (ptr) {
+            size_t shift = (ci->ptype) - types;
+            swig_type_info *ty = types_initial[shift];
+            size_t ldoc = (c - methods[i].ml_doc);
+            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+            char *ndoc = (char*)malloc(ldoc + lptr + 10);
+            if (ndoc) {
+              char *buff = ndoc;
               strncpy(buff, methods[i].ml_doc, ldoc);
               buff += ldoc;
               strncpy(buff, "swig_ptr: ", 10);

Modified: trunk/scipy/sparse/sparsetools/csr.py
===================================================================
--- trunk/scipy/sparse/sparsetools/csr.py	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/csr.py	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.40
+# Version 2.0.1+capsulehack
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.

Modified: trunk/scipy/sparse/sparsetools/csr_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/csr_wrap.cxx	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/csr_wrap.cxx	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.40
+ * Version 2.0.1+capsulehack
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -201,7 +201,7 @@
 /* 
    Flags/methods for returning states.
    
-   The SWIG conversion methods, as ConvertPtr, return and integer 
+   The SWIG conversion methods, as ConvertPtr, return an integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
@@ -1088,9 +1088,6 @@
 
 
 /* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
  * pyrun.swg
  *
  * This file contains the runtime support for Python modules
@@ -1137,8 +1134,18 @@
 #define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
 #define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
 #define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
-#define SWIG_fail                        		goto fail					   
+#define SWIG_fail                        		goto fail				
 
+/*
+ * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
+ * CObjects API.
+ */
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
+#define USE_CAPSULES
+#define TYPE_POINTER_NAME \
+    ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
 
 /* Runtime API implementation */
 
@@ -2071,10 +2078,13 @@
     return SWIG_Python_str_FromChar("this");
 }
 
+static PyObject *swig_this = NULL;
+
 SWIGRUNTIME PyObject *
 SWIG_This(void)
 {
-  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+  if (swig_this == NULL)
+    swig_this = _SWIG_This();
   return swig_this;
 }
 
@@ -2178,7 +2188,7 @@
               int newmemory = 0;
               *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
               if (newmemory == SWIG_CAST_NEW_MEMORY) {
-                assert(own);
+                assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
                 if (own)
                   *own = *own | SWIG_CAST_NEW_MEMORY;
               }
@@ -2448,8 +2458,12 @@
 #ifdef SWIG_LINK_RUNTIME
     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 #else
+#ifdef USE_CAPSULES
+    type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
+#else
     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+#endif
     if (PyErr_Occurred()) {
       PyErr_Clear();
       type_pointer = (void *)0;
@@ -2494,9 +2508,14 @@
 SWIGRUNTIME void
 SWIG_Python_DestroyModule(void *vptr)
 {
+  size_t i;
+#ifdef USE_CAPSULES
+  swig_module_info *swig_module =
+    (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
+#else
   swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
   swig_type_info **types = swig_module->types;
-  size_t i;
   for (i =0; i < swig_module->size; ++i) {
     swig_type_info *ty = types[i];
     if (ty->owndata) {
@@ -2505,6 +2524,7 @@
     }
   }
   Py_DECREF(SWIG_This());
+  swig_this = NULL;
 }
 
 SWIGRUNTIME void
@@ -2518,9 +2538,18 @@
   PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				   swig_empty_runtime_method_table);
 #endif
+#ifdef USE_CAPSULES
+  PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
+				    (PyCapsule_Destructor)SWIG_Python_DestroyModule);
+#else
   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+#endif
   if (pointer && module) {
+#ifdef USE_CAPSULES
+    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+#else
     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+#endif
   } else {
     Py_XDECREF(pointer);
   }
@@ -2541,12 +2570,20 @@
   PyObject *obj = PyDict_GetItem(cache, key);
   swig_type_info *descriptor;
   if (obj) {
+#ifdef USE_CAPSULES
+    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
+#else
     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
   } else {
     swig_module_info *swig_module = SWIG_Python_GetModule();
     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
     if (descriptor) {
+#ifdef USE_CAPSULES
+      obj = PyCapsule_New(descriptor, type, NULL);
+#else
       obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
       PyDict_SetItem(cache, key, obj);
       Py_DECREF(obj);
     }
@@ -2722,7 +2759,7 @@
 #endif
 #define SWIG_name    "_csr"
 
-#define SWIGVERSION 0x010340 
+#define SWIGVERSION 0x020001 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -5728,7 +5765,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_diagonal'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_diagonal'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_diagonal< int,signed char >(int const,int const,int const [],int const [],signed char const [],signed char [])\n"
     "    csr_diagonal< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],unsigned char [])\n"
@@ -7804,7 +7841,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_scale_rows'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_scale_rows'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_scale_rows< int,signed char >(int const,int const,int const [],int const [],signed char [],signed char const [])\n"
     "    csr_scale_rows< int,unsigned char >(int const,int const,int const [],int const [],unsigned char [],unsigned char const [])\n"
@@ -9880,7 +9917,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_scale_columns'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_scale_columns'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_scale_columns< int,signed char >(int const,int const,int const [],int const [],signed char [],signed char const [])\n"
     "    csr_scale_columns< int,unsigned char >(int const,int const,int const [],int const [],unsigned char [],unsigned char const [])\n"
@@ -12320,7 +12357,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_tocsc'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_tocsc'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_tocsc< int,signed char >(int const,int const,int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csr_tocsc< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -15180,7 +15217,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_tobsr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_tobsr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_tobsr< int,signed char >(int const,int const,int const,int const,int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csr_tobsr< int,unsigned char >(int const,int const,int const,int const,int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -18838,7 +18875,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_matmat_pass2'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_matmat_pass2'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_matmat_pass2< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csr_matmat_pass2< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -21320,7 +21357,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_matvec'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_matvec'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_matvec< int,signed char >(int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n"
     "    csr_matvec< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -24012,7 +24049,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_matvecs'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_matvecs'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_matvecs< int,signed char >(int const,int const,int const,int const [],int const [],signed char const [],signed char const [],signed char [])\n"
     "    csr_matvecs< int,unsigned char >(int const,int const,int const,int const [],int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -27670,7 +27707,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_elmul_csr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_elmul_csr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_elmul_csr< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csr_elmul_csr< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -31328,7 +31365,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_eldiv_csr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_eldiv_csr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_eldiv_csr< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csr_eldiv_csr< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -34986,7 +35023,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_plus_csr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_plus_csr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_plus_csr< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csr_plus_csr< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -38644,7 +38681,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_minus_csr'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_minus_csr'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_minus_csr< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const [],int const [],signed char const [],int [],int [],signed char [])\n"
     "    csr_minus_csr< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const [],int const [],unsigned char const [],int [],int [],unsigned char [])\n"
@@ -39880,7 +39917,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_sort_indices'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_sort_indices'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_sort_indices< int,signed char >(int const,int const [],int [],signed char [])\n"
     "    csr_sort_indices< int,unsigned char >(int const,int const [],int [],unsigned char [])\n"
@@ -41102,7 +41139,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_eliminate_zeros'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_eliminate_zeros'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_eliminate_zeros< int,signed char >(int const,int const,int [],int [],signed char [])\n"
     "    csr_eliminate_zeros< int,unsigned char >(int const,int const,int [],int [],unsigned char [])\n"
@@ -42324,7 +42361,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_sum_duplicates'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_sum_duplicates'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_sum_duplicates< int,signed char >(int const,int const,int [],int [],signed char [])\n"
     "    csr_sum_duplicates< int,unsigned char >(int const,int const,int [],int [],unsigned char [])\n"
@@ -45604,7 +45641,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'get_csr_submatrix'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'get_csr_submatrix'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    get_csr_submatrix< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const,int const,int const,int const,std::vector< int > *,std::vector< int > *,std::vector< signed char > *)\n"
     "    get_csr_submatrix< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const,int const,int const,int const,std::vector< int > *,std::vector< int > *,std::vector< unsigned char > *)\n"
@@ -48702,7 +48739,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'csr_sample_values'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'csr_sample_values'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    csr_sample_values< int,signed char >(int const,int const,int const [],int const [],signed char const [],int const,int const [],int const [],signed char [])\n"
     "    csr_sample_values< int,unsigned char >(int const,int const,int const [],int const [],unsigned char const [],int const,int const [],int const [],unsigned char [])\n"
@@ -49838,15 +49875,15 @@
           }
         }
         if (ci) {
-          size_t shift = (ci->ptype) - types;
-          swig_type_info *ty = types_initial[shift];
-          size_t ldoc = (c - methods[i].ml_doc);
-          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-          char *ndoc = (char*)malloc(ldoc + lptr + 10);
-          if (ndoc) {
-            char *buff = ndoc;
-            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-            if (ptr) {
+          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+          if (ptr) {
+            size_t shift = (ci->ptype) - types;
+            swig_type_info *ty = types_initial[shift];
+            size_t ldoc = (c - methods[i].ml_doc);
+            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+            char *ndoc = (char*)malloc(ldoc + lptr + 10);
+            if (ndoc) {
+              char *buff = ndoc;
               strncpy(buff, methods[i].ml_doc, ldoc);
               buff += ldoc;
               strncpy(buff, "swig_ptr: ", 10);

Modified: trunk/scipy/sparse/sparsetools/dia.py
===================================================================
--- trunk/scipy/sparse/sparsetools/dia.py	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/dia.py	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,5 +1,5 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 1.3.40
+# Version 2.0.1+capsulehack
 #
 # Do not make changes to this file unless you know what you are doing--modify
 # the SWIG interface file instead.

Modified: trunk/scipy/sparse/sparsetools/dia_wrap.cxx
===================================================================
--- trunk/scipy/sparse/sparsetools/dia_wrap.cxx	2011-01-20 12:18:52 UTC (rev 7070)
+++ trunk/scipy/sparse/sparsetools/dia_wrap.cxx	2011-01-22 22:07:40 UTC (rev 7071)
@@ -1,6 +1,6 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.40
+ * Version 2.0.1+capsulehack
  * 
  * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
@@ -201,7 +201,7 @@
 /* 
    Flags/methods for returning states.
    
-   The SWIG conversion methods, as ConvertPtr, return and integer 
+   The SWIG conversion methods, as ConvertPtr, return an integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
    
@@ -1088,9 +1088,6 @@
 
 
 /* -----------------------------------------------------------------------------
- * See the LICENSE file for information on copyright, usage and redistribution
- * of SWIG, and the README file for authors - http://www.swig.org/release.html.
- *
  * pyrun.swg
  *
  * This file contains the runtime support for Python modules
@@ -1137,8 +1134,18 @@
 #define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
 #define SWIG_ErrorType(code)                    	SWIG_Python_ErrorType(code)                        
 #define SWIG_Error(code, msg)            		SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 
-#define SWIG_fail                        		goto fail					   
+#define SWIG_fail                        		goto fail				
 
+/*
+ * Python 2.7 and newer and Python 3.1 and newer should use Capsules API instead of
+ * CObjects API.
+ */
+#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
+     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0))
+#define USE_CAPSULES
+#define TYPE_POINTER_NAME \
+    ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
+#endif
 
 /* Runtime API implementation */
 
@@ -2071,10 +2078,13 @@
     return SWIG_Python_str_FromChar("this");
 }
 
+static PyObject *swig_this = NULL;
+
 SWIGRUNTIME PyObject *
 SWIG_This(void)
 {
-  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+  if (swig_this == NULL)
+    swig_this = _SWIG_This();
   return swig_this;
 }
 
@@ -2178,7 +2188,7 @@
               int newmemory = 0;
               *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
               if (newmemory == SWIG_CAST_NEW_MEMORY) {
-                assert(own);
+                assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
                 if (own)
                   *own = *own | SWIG_CAST_NEW_MEMORY;
               }
@@ -2448,8 +2458,12 @@
 #ifdef SWIG_LINK_RUNTIME
     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 #else
+#ifdef USE_CAPSULES
+    type_pointer = PyCapsule_Import(TYPE_POINTER_NAME, 0);
+#else
     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
+#endif
     if (PyErr_Occurred()) {
       PyErr_Clear();
       type_pointer = (void *)0;
@@ -2494,9 +2508,14 @@
 SWIGRUNTIME void
 SWIG_Python_DestroyModule(void *vptr)
 {
+  size_t i;
+#ifdef USE_CAPSULES
+  swig_module_info *swig_module =
+    (swig_module_info *) PyCapsule_GetPointer((PyObject *)vptr, TYPE_POINTER_NAME);
+#else
   swig_module_info *swig_module = (swig_module_info *) vptr;
+#endif
   swig_type_info **types = swig_module->types;
-  size_t i;
   for (i =0; i < swig_module->size; ++i) {
     swig_type_info *ty = types[i];
     if (ty->owndata) {
@@ -2505,6 +2524,7 @@
     }
   }
   Py_DECREF(SWIG_This());
+  swig_this = NULL;
 }
 
 SWIGRUNTIME void
@@ -2518,9 +2538,18 @@
   PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				   swig_empty_runtime_method_table);
 #endif
+#ifdef USE_CAPSULES
+  PyObject *pointer = PyCapsule_New((void *)swig_module, TYPE_POINTER_NAME,
+				    (PyCapsule_Destructor)SWIG_Python_DestroyModule);
+#else
   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
+#endif
   if (pointer && module) {
+#ifdef USE_CAPSULES
+    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
+#else
     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
+#endif
   } else {
     Py_XDECREF(pointer);
   }
@@ -2541,12 +2570,20 @@
   PyObject *obj = PyDict_GetItem(cache, key);
   swig_type_info *descriptor;
   if (obj) {
+#ifdef USE_CAPSULES
+    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, type);
+#else
     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
+#endif
   } else {
     swig_module_info *swig_module = SWIG_Python_GetModule();
     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
     if (descriptor) {
+#ifdef USE_CAPSULES
+      obj = PyCapsule_New(descriptor, type, NULL);
+#else
       obj = PyCObject_FromVoidPtr(descriptor, NULL);
+#endif
       PyDict_SetItem(cache, key, obj);
       Py_DECREF(obj);
     }
@@ -2708,7 +2745,7 @@
 #endif
 #define SWIG_name    "_dia"
 
-#define SWIGVERSION 0x010340 
+#define SWIGVERSION 0x020001 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -5749,7 +5786,7 @@
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'dia_matvec'.\n"
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'dia_matvec'.\n"
     "  Possible C/C++ prototypes are:\n"
     "    dia_matvec< int,signed char >(int const,int const,int const,int const,int const [],signed char const [],signed char const [],signed char [])\n"
     "    dia_matvec< int,unsigned char >(int const,int const,int const,int const,int const [],unsigned char const [],unsigned char const [],unsigned char [])\n"
@@ -6345,15 +6382,15 @@
           }
         }
         if (ci) {
-          size_t shift = (ci->ptype) - types;
-          swig_type_info *ty = types_initial[shift];
-          size_t ldoc = (c - methods[i].ml_doc);
-          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-          char *ndoc = (char*)malloc(ldoc + lptr + 10);
-          if (ndoc) {
-            char *buff = ndoc;
-            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-            if (ptr) {
+          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+          if (ptr) {
+            size_t shift = (ci->ptype) - types;
+            swig_type_info *ty = types_initial[shift];
+            size_t ldoc = (c - methods[i].ml_doc);
+            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+            char *ndoc = (char*)malloc(ldoc + lptr + 10);
+            if (ndoc) {
+              char *buff = ndoc;
               strncpy(buff, methods[i].ml_doc, ldoc);
               buff += ldoc;
               strncpy(buff, "swig_ptr: ", 10);




More information about the Scipy-svn mailing list