2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-20 04:42:28 +00:00
Files
python/src/numpy/numpy.cpp
Moritz Wanzenböck ed4776b59c Add missing return statement in numpy import
This adds a missing return statement in the python3 specific
import logic of boost.python.numpy.

For python3 wrap_import_array() needs to return a pointer value.
The import_array() macro only returns NULL in case of error. The
missing return statement is UB, so the compiler can assume it does
not happen. This means the compiler can assume the error branch
is always taken, so import_array must always fail.
2018-07-11 16:40:19 -04:00

35 lines
777 B
C++

// Copyright Jim Bosch 2010-2012.
// Copyright Stefan Seefeld 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_PYTHON_NUMPY_INTERNAL_MAIN
#include <boost/python/numpy/internal.hpp>
#include <boost/python/numpy/dtype.hpp>
namespace boost { namespace python { namespace numpy {
#if PY_MAJOR_VERSION == 2
static void wrap_import_array()
{
import_array();
}
#else
static void * wrap_import_array()
{
import_array();
return NULL;
}
#endif
void initialize(bool register_scalar_converters)
{
wrap_import_array();
import_ufunc();
if (register_scalar_converters)
dtype::register_scalar_converters();
}
}}} // namespace boost::python::numpy