mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 16:32:16 +00:00
Compare commits
13 Commits
boost-1.68
...
pr/fix-num
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c8b0dc215 | ||
|
|
fdc9ec760f | ||
|
|
0b0c0536d6 | ||
|
|
0d0cd711a7 | ||
|
|
72e254bf8b | ||
|
|
1f1b9b6aef | ||
|
|
6bd6d71850 | ||
|
|
4b01139720 | ||
|
|
65bfec2d97 | ||
|
|
4f6d547c0a | ||
|
|
b644946368 | ||
|
|
c7799aa44f | ||
|
|
02095af952 |
@@ -30,8 +30,6 @@ else
|
||||
;
|
||||
}
|
||||
|
||||
if [ python.configured ]
|
||||
{
|
||||
project boost/python
|
||||
: source-location ../src
|
||||
;
|
||||
@@ -123,7 +121,7 @@ lib boost_numpy
|
||||
<library>boost_python
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
-<tag>@$(BOOST_JAMROOT_MODULE)%$(BOOST_JAMROOT_MODULE).tag
|
||||
<tag>@$(__name__).python-tag
|
||||
<tag>@$(__name__).python-tag
|
||||
<conditional>@python.require-py
|
||||
|
||||
: # default build
|
||||
@@ -132,4 +130,38 @@ lib boost_numpy
|
||||
<link>static:<define>BOOST_NUMPY_STATIC_LIB
|
||||
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||
;
|
||||
}
|
||||
|
||||
# boost-install creates `stage` and `install` targets
|
||||
#
|
||||
# `stage` stages (builds and copies into `stage/lib`) the given libraries
|
||||
# `boost_python` and `boost_numpy` and their dependencies and is similar
|
||||
# to issuing `b2 --with-python stage` from top level
|
||||
#
|
||||
# `install` installs the two libraries and their dependencies and is similar
|
||||
# to issuing `b2 --with-python install` from top level
|
||||
|
||||
if [ python.configured ]
|
||||
{
|
||||
if [ python.numpy ]
|
||||
{
|
||||
boost-install boost_python boost_numpy ;
|
||||
}
|
||||
else
|
||||
{
|
||||
boost-install boost_python ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
# When Python isn't configured, the above `boost-install` is not executed,
|
||||
# so we create empty `stage` and `install` targets that do nothing but issue
|
||||
# a warning message unless `--without-python` is given
|
||||
|
||||
alias stage : config-warning ;
|
||||
explicit stage ;
|
||||
|
||||
alias install : config-warning ;
|
||||
explicit install ;
|
||||
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ __jam__
|
||||
file. Simply copy the file and tweak [^use-project boost] to where your
|
||||
boost root directory is and you're OK.
|
||||
|
||||
The comments contained in the Jamrules file above should be sufficient
|
||||
The comments contained in the Jamroot file above should be sufficient
|
||||
to get you going.
|
||||
|
||||
[h2 Running bjam]
|
||||
|
||||
@@ -109,6 +109,23 @@ struct converter_target_type <void_result_to_python >
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// Generation of ret moved from caller_arity<N>::impl::signature to here due to "feature" in MSVC 15.7.2 with /O2
|
||||
// which left the ret uninitialized and caused segfaults in Python interpreter.
|
||||
template<class Policies, class Sig> const signature_element* get_ret()
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type<Sig>::type rtype;
|
||||
typedef typename select_result_converter<Policies, rtype>::type result_converter;
|
||||
|
||||
static const signature_element ret = {
|
||||
(is_void<rtype>::value ? "void" : type_id<rtype>().name())
|
||||
, &detail::converter_target_type<result_converter>::get_pytype
|
||||
, boost::detail::indirect_traits::is_reference_to_non_const<rtype>::value
|
||||
};
|
||||
|
||||
return &ret;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -229,16 +246,12 @@ struct caller_arity<N>
|
||||
{
|
||||
const signature_element * sig = detail::signature<Sig>::elements();
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
// MSVC 15.7.2, when compiling to /O2 left the static const signature_element ret,
|
||||
// originally defined here, uninitialized. This in turn led to SegFault in Python interpreter.
|
||||
// Issue is resolved by moving the generation of ret to separate function in detail namespace (see above).
|
||||
const signature_element * ret = detail::get_ret<Policies, Sig>();
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME Policies::template extract_return_type<Sig>::type rtype;
|
||||
typedef typename select_result_converter<Policies, rtype>::type result_converter;
|
||||
|
||||
static const signature_element ret = {
|
||||
(is_void<rtype>::value ? "void" : type_id<rtype>().name())
|
||||
, &detail::converter_target_type<result_converter>::get_pytype
|
||||
, boost::detail::indirect_traits::is_reference_to_non_const<rtype>::value
|
||||
};
|
||||
py_func_sig_info res = {sig, &ret };
|
||||
py_func_sig_info res = {sig, ret };
|
||||
#else
|
||||
py_func_sig_info res = {sig, sig };
|
||||
#endif
|
||||
|
||||
@@ -11,13 +11,15 @@
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
#ifndef _MSC_VER //if forward declared, msvc6.5 does not recognize them as inline
|
||||
// forward declaration, required (at least) by Tru64 cxx V6.5-042
|
||||
#if (!defined(_MSC_VER) || _MSC_VER >= 1915)
|
||||
// If forward declared, msvc6.5 does not recognize them as inline.
|
||||
// However, as of msvc14.15 (_MSC_VER 1915/Visual Studio 15.8.0) name lookup is now consistent with other compilers.
|
||||
// forward declaration, required (at least) by Tru64 cxx V6.5-042 and msvc14.15
|
||||
template <class Generator, class U>
|
||||
inline typename Generator::result_type
|
||||
unwind_type(U const& p, Generator* = 0);
|
||||
|
||||
// forward declaration, required (at least) by Tru64 cxx V6.5-042
|
||||
// forward declaration, required (at least) by Tru64 cxx V6.5-042 and msvc14.15
|
||||
template <class Generator, class U>
|
||||
inline typename Generator::result_type
|
||||
unwind_type(boost::type<U>*p = 0, Generator* = 0);
|
||||
@@ -83,7 +85,7 @@ struct unwind_helper<false>
|
||||
|
||||
template <class Generator, class U>
|
||||
inline typename Generator::result_type
|
||||
#ifndef _MSC_VER
|
||||
#if (!defined(_MSC_VER) || _MSC_VER >= 1915)
|
||||
unwind_type(U const& p, Generator*)
|
||||
#else
|
||||
unwind_type(U const& p, Generator* = 0)
|
||||
@@ -148,7 +150,7 @@ struct unwind_helper2<reference_to_pointer_>
|
||||
// why bother?
|
||||
template <class Generator, class U>
|
||||
inline typename Generator::result_type
|
||||
#ifndef _MSC_VER
|
||||
#if (!defined(_MSC_VER) || _MSC_VER >= 1915)
|
||||
unwind_type(boost::type<U>*, Generator*)
|
||||
#else
|
||||
unwind_type(boost::type<U>*p =0, Generator* =0)
|
||||
|
||||
@@ -47,6 +47,13 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// pyconfig.h defines a macro with hypot name, what breaks libstdc++ math headers
|
||||
// that Python.h tries to include afterwards.
|
||||
#if defined(__MINGW32__)
|
||||
# include <cmath>
|
||||
# include <math.h>
|
||||
#endif
|
||||
|
||||
# include <pyconfig.h>
|
||||
# if defined(_SGI_COMPILER_VERSION) && _SGI_COMPILER_VERSION >= 740
|
||||
# undef _POSIX_C_SOURCE
|
||||
@@ -83,6 +90,7 @@
|
||||
// than MSVC on Win32
|
||||
//
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
# if defined(__GNUC__) && defined(__CYGWIN__)
|
||||
|
||||
# if defined(__LP64__)
|
||||
@@ -145,12 +153,38 @@ typedef int pid_t;
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if defined(__has_warning)
|
||||
# define BOOST_PYTHON_GCC_HAS_WREGISTER __has_warning("-Wregister")
|
||||
# else
|
||||
# define BOOST_PYTHON_GCC_HAS_WREGISTER __GNUC__ >= 7
|
||||
# endif
|
||||
#else
|
||||
# define BOOST_PYTHON_GCC_HAS_WREGISTER 0
|
||||
#endif
|
||||
|
||||
// Python.h header uses `register` keyword until Python 3.4
|
||||
#if BOOST_PYTHON_GCC_HAS_WREGISTER
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wregister"
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 5033) // 'register' is no longer a supported storage class
|
||||
#endif
|
||||
|
||||
#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
|
||||
# include <boost/python/detail/python22_fixed.h>
|
||||
#else
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#if BOOST_PYTHON_GCC_HAS_WREGISTER
|
||||
# pragma GCC diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
#undef BOOST_PYTHON_GCC_HAS_WREGISTER
|
||||
|
||||
#ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
|
||||
# undef ULONG_MAX
|
||||
# undef BOOST_PYTHON_ULONG_MAX_UNDEFINED
|
||||
|
||||
@@ -73,7 +73,7 @@ class list : public detail::list_base
|
||||
}
|
||||
|
||||
template <class T>
|
||||
long count(T const& value) const
|
||||
ssize_t count(T const& value) const
|
||||
{
|
||||
return base::count(object(value));
|
||||
}
|
||||
|
||||
@@ -444,7 +444,9 @@ void function::add_to_namespace(
|
||||
if (dict == 0)
|
||||
throw_error_already_set();
|
||||
|
||||
assert(!PyErr_Occurred());
|
||||
handle<> existing(allow_null(::PyObject_GetItem(dict.get(), name.ptr())));
|
||||
PyErr_Clear();
|
||||
|
||||
if (existing)
|
||||
{
|
||||
@@ -485,16 +487,15 @@ void function::add_to_namespace(
|
||||
if (new_func->name().is_none())
|
||||
new_func->m_name = name;
|
||||
|
||||
assert(!PyErr_Occurred());
|
||||
handle<> name_space_name(
|
||||
allow_null(::PyObject_GetAttrString(name_space.ptr(), const_cast<char*>("__name__"))));
|
||||
PyErr_Clear();
|
||||
|
||||
if (name_space_name)
|
||||
new_func->m_namespace = object(name_space_name);
|
||||
}
|
||||
|
||||
// The PyObject_GetAttrString() or PyObject_GetItem calls above may
|
||||
// have left an active error
|
||||
PyErr_Clear();
|
||||
if (PyObject_SetAttr(ns, name.ptr(), attribute.ptr()) < 0)
|
||||
throw_error_already_set();
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef TEST_CLASS_DWA2002326_HPP
|
||||
# define TEST_CLASS_DWA2002326_HPP
|
||||
# include <boost/detail/lightweight_test.hpp>
|
||||
# include <boost/assert.hpp>
|
||||
|
||||
template <int n = 0>
|
||||
struct test_class
|
||||
{
|
||||
explicit test_class(int x) : x(x), magic(7654321 + n) { ++counter; }
|
||||
test_class(test_class const& rhs) : x(rhs.x), magic(7654321 + n) { ++counter; }
|
||||
virtual ~test_class() { BOOST_TEST(magic == 7654321 + n); magic = 6666666; x = 9999; --counter; }
|
||||
virtual ~test_class() { BOOST_ASSERT(magic == 7654321 + n); magic = 6666666; x = 9999; --counter; }
|
||||
|
||||
void set(int _x) { BOOST_TEST(magic == 7654321 + n); this->x = _x; }
|
||||
int value() const { BOOST_TEST(magic == 7654321 + n); return x; }
|
||||
void set(int _x) { BOOST_ASSERT(magic == 7654321 + n); this->x = _x; }
|
||||
int value() const { BOOST_ASSERT(magic == 7654321 + n); return x; }
|
||||
operator int() const { return x; }
|
||||
static int count() { return counter; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user