changeset 111:f89a4eb2e864

pytave::init: Make compatible with Python 3 module initialization * pytave.cc (pytave::init): Make return type compatible with Python 3 module initialization. Ensure NumPy's init_module is called last.
author Mike Miller <mtmiller@octave.org>
date Sun, 20 Sep 2015 01:41:50 +0200
parents b0cc112a31d2
children ca8bdbe49a94
files pytave.cc
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pytave.cc	Sun Sep 20 01:39:10 2015 +0200
+++ b/pytave.cc	Sun Sep 20 01:41:50 2015 +0200
@@ -61,7 +61,7 @@
    locale_t c_locale;
 #endif
 
-   void init(bool silent = true) {
+   PyMODINIT_FUNC init(bool silent = true) {
 #ifdef HAVE_USELOCALE
       c_locale = newlocale(LC_ALL, "C", 0);
 #endif
@@ -72,7 +72,7 @@
           || !octave_parse_exception::init()
           || !variable_name_exception::init ()) {
          PyErr_SetString(PyExc_ImportError, "_pytave: init failed");
-         return;
+         return NULL;
       }
 
       // Initialize Octave.
@@ -104,12 +104,12 @@
 
       // Initialize NumPy Array
 
+      // Let boost use numpy
+      numeric::array::set_module_and_type ("numpy", "ndarray");
+
       // This is actually a macro that becomes a block expression. If an error
       // occurs, e.g. NumPy not installed, an exception is set.
       import_array()
-
-      // Let boost use numpy
-      numeric::array::set_module_and_type ("numpy", "ndarray");
    }
 
    boost::python::tuple get_exceptions() {