Index: src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp
===================================================================
--- src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp	(revision b523c0e4093c0c8e82cebd10672473d88adeaee9)
+++ src/sas/sascalc/calculator/c_extensions/sld2i_module.cpp	(revision d04ac056c476a91de374975fdb618e1cf1d27ca1)
@@ -5,4 +5,12 @@
 #include <stdio.h>
 #include <sld2i.hh>
+
+#if PY_MAJOR_VERSION < 3
+typedef void (*PyCapsule_Destructor)(PyObject *);
+typedef void (*PyCObject_Destructor)(void *);
+#define PyCapsule_New(pointer, name, destructor) (PyCObject_FromVoidPtr(pointer, (PyCObject_Destructor)destructor))
+#define PyCapsule_GetPointer(capsule, name) (PyCObject_AsVoidPtr(capsule))
+#endif
+
 
 // Utilities
@@ -25,6 +33,7 @@
  * Delete a GenI object
  */
-void del_sld2i(void *ptr){
-	GenI* sld2i = static_cast<GenI *>(ptr);
+void
+del_sld2i(PyObject *obj){
+	GenI* sld2i = static_cast<GenI *>(PyCapsule_GetPointer(obj, "GenI"));
 	delete sld2i;
 	return;
@@ -71,5 +80,5 @@
 	OUTVECTOR(vol_pix_obj, vol_pix, n_x);
 	GenI* sld2i = new GenI(n_pix,x_val,y_val,z_val,sldn_val,mx_val,my_val,mz_val,vol_pix,inspin,outspin,stheta);
-	return PyCObject_FromVoidPtr(sld2i, del_sld2i);
+	return PyCapsule_New(sld2i, "GenI", del_sld2i);
 }
 
@@ -97,5 +106,5 @@
 
 	// Set the array pointers
-	void *temp = PyCObject_AsVoidPtr(gen_obj);
+	void *temp = PyCapsule_GetPointer(gen_obj, "GenI");
 	GenI* s = static_cast<GenI *>(temp);
 
@@ -125,5 +134,5 @@
 
 	// Set the array pointers
-	void *temp = PyCObject_AsVoidPtr(gen_obj);
+	void *temp = PyCapsule_GetPointer(gen_obj, "GenI");
 	GenI* s = static_cast<GenI *>(temp);
 
@@ -146,11 +155,48 @@
 };
 
-
-#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
+#define MODULE_DOC "Sld2i C Library"
+#define MODULE_NAME "sld2i"
+#define MODULE_INIT2 initsld2i
+#define MODULE_INIT3 PyInit_reflmodule
+#define MODULE_METHODS module_methods
+
+/* ==== boilerplate python 2/3 interface bootstrap ==== */
+
+
+#if defined(WIN32) && !defined(__MINGW32__)
+    #define DLL_EXPORT __declspec(dllexport)
+#else
+    #define DLL_EXPORT
 #endif
-PyMODINIT_FUNC
-initsld2i(void)
-{
-    Py_InitModule3("sld2i", module_methods, "Sld2i module");
-}
+
+#if PY_MAJOR_VERSION >= 3
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT3(void)
+  {
+    static struct PyModuleDef moduledef = {
+      PyModuleDef_HEAD_INIT,
+      MODULE_NAME,         /* m_name */
+      MODULE_DOC,          /* m_doc */
+      -1,                  /* m_size */
+      MODULE_METHODS,      /* m_methods */
+      NULL,                /* m_reload */
+      NULL,                /* m_traverse */
+      NULL,                /* m_clear */
+      NULL,                /* m_free */
+    };
+    return PyModule_Create(&moduledef);
+  }
+
+#else /* !PY_MAJOR_VERSION >= 3 */
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT2(void)
+  {
+    Py_InitModule4(MODULE_NAME,
+		 MODULE_METHODS,
+		 MODULE_DOC,
+		 0,
+		 PYTHON_API_VERSION
+		 );
+  }
+
+#endif /* !PY_MAJOR_VERSION >= 3 */
Index: src/sas/sascalc/file_converter/c_ext/bsl_loader.c
===================================================================
--- src/sas/sascalc/file_converter/c_ext/bsl_loader.c	(revision 2ab9c432bb247d0039ef9051ec98bfdcdc8a7021)
+++ src/sas/sascalc/file_converter/c_ext/bsl_loader.c	(revision d04ac056c476a91de374975fdb618e1cf1d27ca1)
@@ -1,4 +1,4 @@
 #include <Python.h>
-//#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
 #include <numpy/arrayobject.h>
 #include <stdio.h>
@@ -44,5 +44,5 @@
 static void CLoader_dealloc(CLoader *self) {
     free(self->params.filename);
-    self->ob_type->tp_free((PyObject *)self);
+    Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
@@ -237,6 +237,7 @@
 
 static PyTypeObject CLoaderType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
+    //PyObject_HEAD_INIT(NULL)
+    //0,                         /*ob_size*/
+    PyVarObject_HEAD_INIT(NULL, 0)
     "CLoader",             /*tp_name*/
     sizeof(CLoader),             /*tp_basicsize*/
@@ -278,15 +279,68 @@
 };
 
-PyMODINIT_FUNC
-initbsl_loader(void)
-{
-    PyObject *module;
-    module = Py_InitModule("bsl_loader", NULL);
-    import_array();
-
+static PyMethodDef module_methods[] = {
+    {NULL}
+};
+
+/**
+ * Function used to add the model class to a module
+ * @param module: module to add the class to
+ */
+void addCLoader(PyObject *module) {
     if (PyType_Ready(&CLoaderType) < 0)
         return;
 
     Py_INCREF(&CLoaderType);
-    PyModule_AddObject(module, "CLoader", (PyObject *)&CLoaderType);
-}
+    PyModule_AddObject(module, "bsl_loader", (PyObject *)&CLoaderType);
+}
+
+
+#define MODULE_DOC "C module for loading bsl."
+#define MODULE_NAME "bsl_loader"
+#define MODULE_INIT2 initbsl_loader
+#define MODULE_INIT3 PyInit_bsl_loader
+#define MODULE_METHODS module_methods
+
+/* ==== boilerplate python 2/3 interface bootstrap ==== */
+
+
+#if defined(WIN32) && !defined(__MINGW32__)
+    #define DLL_EXPORT __declspec(dllexport)
+#else
+    #define DLL_EXPORT
+#endif
+
+#if PY_MAJOR_VERSION >= 3
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT3(void)
+  {
+    static struct PyModuleDef moduledef = {
+      PyModuleDef_HEAD_INIT,
+      MODULE_NAME,         /* m_name */
+      MODULE_DOC,          /* m_doc */
+      -1,                  /* m_size */
+      MODULE_METHODS,      /* m_methods */
+      NULL,                /* m_reload */
+      NULL,                /* m_traverse */
+      NULL,                /* m_clear */
+      NULL,                /* m_free */
+    };
+	PyObject* m = PyModule_Create(&moduledef);
+	addCLoader(m);
+	return m;
+  }
+
+#else /* !PY_MAJOR_VERSION >= 3 */
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT2(void)
+  {
+    PyObject* m = Py_InitModule4(MODULE_NAME,
+		 MODULE_METHODS,
+		 MODULE_DOC,
+		 0,
+		 PYTHON_API_VERSION
+		 );
+	addCLoader(m);
+  }
+
+#endif /* !PY_MAJOR_VERSION >= 3 */
Index: src/sas/sascalc/pr/c_extensions/Cinvertor.c
===================================================================
--- src/sas/sascalc/pr/c_extensions/Cinvertor.c	(revision cb62bd55ae79395ac6e01d8b2077f4d496625c41)
+++ src/sas/sascalc/pr/c_extensions/Cinvertor.c	(revision d04ac056c476a91de374975fdb618e1cf1d27ca1)
@@ -52,5 +52,5 @@
     invertor_dealloc(&(self->params));
 
-    self->ob_type->tp_free((PyObject*)self);
+    Py_TYPE(self)->tp_free((PyObject*)self);
 
 }
@@ -1054,6 +1054,7 @@
 
 static PyTypeObject CinvertorType = {
-    PyObject_HEAD_INIT(NULL)
-    0,                         /*ob_size*/
+    //PyObject_HEAD_INIT(NULL)
+    //0,                         /*ob_size*/
+    PyVarObject_HEAD_INIT(NULL, 0)
     "Cinvertor",             /*tp_name*/
     sizeof(Cinvertor),             /*tp_basicsize*/
@@ -1119,15 +1120,51 @@
 
 
-#ifndef PyMODINIT_FUNC	/* declarations for DLL import/export */
-#define PyMODINIT_FUNC void
+#define MODULE_DOC "C extension module for inversion to P(r)."
+#define MODULE_NAME "pr_inversion"
+#define MODULE_INIT2 initpr_inversion
+#define MODULE_INIT3 PyInit_pr_inversion
+#define MODULE_METHODS module_methods
+
+/* ==== boilerplate python 2/3 interface bootstrap ==== */
+
+
+#if defined(WIN32) && !defined(__MINGW32__)
+    #define DLL_EXPORT __declspec(dllexport)
+#else
+    #define DLL_EXPORT
 #endif
-PyMODINIT_FUNC
-initpr_inversion(void)
-{
-    PyObject* m;
-
-    m = Py_InitModule3("pr_inversion", module_methods,
-                       "C extension module for inversion to P(r).");
-
-    addCinvertor(m);
-}
+
+#if PY_MAJOR_VERSION >= 3
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT3(void)
+  {
+    static struct PyModuleDef moduledef = {
+      PyModuleDef_HEAD_INIT,
+      MODULE_NAME,         /* m_name */
+      MODULE_DOC,          /* m_doc */
+      -1,                  /* m_size */
+      MODULE_METHODS,      /* m_methods */
+      NULL,                /* m_reload */
+      NULL,                /* m_traverse */
+      NULL,                /* m_clear */
+      NULL,                /* m_free */
+    };
+	PyObject* m = PyModule_Create(&moduledef);
+	addCinvertor(m);
+	return m;
+  }
+
+#else /* !PY_MAJOR_VERSION >= 3 */
+
+  DLL_EXPORT PyMODINIT_FUNC MODULE_INIT2(void)
+  {
+    PyObject* m = Py_InitModule4(MODULE_NAME,
+		 MODULE_METHODS,
+		 MODULE_DOC,
+		 0,
+		 PYTHON_API_VERSION
+		 );
+	addCinvertor(m);
+  }
+
+#endif /* !PY_MAJOR_VERSION >= 3 */
Index: src/sas/sascalc/pr/invertor.py
===================================================================
--- src/sas/sascalc/pr/invertor.py	(revision 574adc767a9e86744546f8edd6a23dc4f81914ad)
+++ src/sas/sascalc/pr/invertor.py	(revision d04ac056c476a91de374975fdb618e1cf1d27ca1)
@@ -472,6 +472,6 @@
         try:
             self._get_matrix(nfunc, nq, a, b)
-        except:
-            raise RuntimeError("Invertor: could not invert I(Q)\n  %s" % sys.exc_value)
+        except Exception as exc:
+            raise RuntimeError("Invertor: could not invert I(Q)\n  %s" % str(exc))
 
         # Perform the inversion (least square fit)
