# HG changeset patch # User Mike Miller # Date 1442706110 -7200 # Node ID f89a4eb2e864505553cc66b46c05340a5a3f0de1 # Parent b0cc112a31d249e06c6d490072a4ea112f03595f 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. diff -r b0cc112a31d2 -r f89a4eb2e864 pytave.cc --- 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() {