2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Compare commits

...

13 Commits

Author SHA1 Message Date
Peter Dimov
8c8b0dc215 Only boost-install boost_numpy when it's being built 2019-04-18 00:02:52 +03:00
Nikita Kniazev
fdc9ec760f Fixed module tests fail
Since recently lightweight_test introduced a sanitation to ensure that
`boost::report_errors()` is called, and it does not in module tests.

The problem could be fixed by exporting the function and calling it from
these python tests, but as it already done in other module tests I just
turned those usages lightweight_test to a regular assertation.
2019-03-31 20:36:56 -04:00
Nikita Kniazev
0b0c0536d6 The right hypot fix for MinGW 2019-03-26 15:56:03 -04:00
Owens
0d0cd711a7 Enable forward declaration of unwind_type() in msvc14.15 and later.
Name lookup in msvc has changed between 14.14 and 14.15 making it consistent with other compilers. Forward declaration of unwind_type() is now required as it is for other compilers.

Resolves compilation errors identified in:

https://github.com/boostorg/python/issues/228
2019-03-25 11:00:48 -04:00
Jonathan Wakely
72e254bf8b Fix name of file in tutorial
I think it's meant to refer to the Jamroot file being discussed, not Jamrules.
2019-03-23 20:38:29 -04:00
Nikita Kniazev
1f1b9b6aef Fix hypot issue on MinGW 2019-03-23 20:37:35 -04:00
Nikita Kniazev
6bd6d71850 Fix -Wregister error on Clang in C++17 mode
Suppresses the warning on GCC, Clang, and MSVC.
2019-03-21 16:40:41 -04:00
Tom Kent
4b01139720 Ssize t warning - trac #3353 (#21)
Fixes msvc unsafe type conversion warning - trac num: 3353
2019-03-03 22:02:57 -05:00
SPKorhonen
65bfec2d97 Fix static object initialization under Visual Studio 2017 (#208)
Fix static object initialization under VS 15.7.2
2019-03-03 21:59:48 -05:00
Orivej Desh
4f6d547c0a clear python exception after expected attribute lookup failure
Python 3.7.0 asserts that attribute lookup functions are called without outstanding exceptions:
https://github.com/python/cpython/blob/v3.7.0a2/Objects/typeobject.c#L3037
Motivation: https://bugs.python.org/issue34068#msg321262
Therefore the error set by the first PyObject_GetItem should be cleared before calling PyObject_GetAttrString.
2019-02-13 23:38:02 -05:00
Peter Dimov
b644946368 Add comments explaining the stage/install targets in build/Jamfile 2018-10-12 14:34:15 -04:00
Peter Dimov
c7799aa44f Add empty stage/install targets when Python is not configured 2018-10-12 14:34:15 -04:00
Peter Dimov
02095af952 Use boost-install in build/Jamfile 2018-10-12 09:42:51 -04:00
8 changed files with 109 additions and 27 deletions

View File

@@ -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 ;
}

View File

@@ -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]

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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));
}

View File

@@ -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();

View File

@@ -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; }