diff --git a/contrib/Metis/proto.h b/contrib/Metis/proto.h
index be7ffb7f622efe39cf55c1d851fb893a3454eb98..306223c5dec888459801c8b1fe190096ae6ce3cf 100644
--- a/contrib/Metis/proto.h
+++ b/contrib/Metis/proto.h
@@ -432,7 +432,7 @@ int *ismalloc(int, int, char *);
 idxtype *idxsmalloc(int, idxtype, char *);
 void *GKmalloc(int, char *);
 #endif
-/*void GKfree(void **,...); */
+/*void GKfree(void **,...);*/
 int *iset(int n, int val, int *x);
 idxtype *idxset(int n, idxtype val, idxtype *x);
 float *sset(int n, float val, float *x);
diff --git a/wrappers/gmshpy/gmshtypemaps.i b/wrappers/gmshpy/gmshtypemaps.i
index 7ff28210aca2ff3cc3f547d6dbcc5e812dfb8931..fa9ec33d24803f81975d78e6b67c8464f1525516 100644
--- a/wrappers/gmshpy/gmshtypemaps.i
+++ b/wrappers/gmshpy/gmshtypemaps.i
@@ -91,10 +91,17 @@
   }
 
   %#ifdef HAVE_NUMPY
+  %#if PY_MAJOR_VERSION==2 && PY_MINOR_VERSION==6
+  static void deleteCapsuleArray(void *capsule)
+  {
+    delete [](double*)(capsule);
+  }
+  %#else
   static void deleteCapsuleArray(PyObject *capsule)
   {
     delete [](double*)PyCapsule_GetPointer(capsule, NULL);
   }
+  %#endif
   PyObject *fullMatrix2PyArray(fullMatrix<double> &fm)
   {
     npy_intp dims[2] = {fm.size1(), fm.size2()};
@@ -107,7 +114,11 @@
     PyArray_UpdateFlags((PyArrayObject*)array, NPY_ARRAY_ALIGNED);
     if (fm.getOwnData()) {
       fm.setOwnData(false);
+      %#if PY_MAJOR_VERSION==2 && PY_MINOR_VERSION==6
+      PyObject *capsule = PyCObject_FromVoidPtr((void*)data, deleteCapsuleArray);
+      %#else
       PyObject *capsule = PyCapsule_New((void*) data, NULL, deleteCapsuleArray);
+      %#endif
       PyArray_SetBaseObject((PyArrayObject*)array, capsule);
     }
     return array;