2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-23 05:42:30 +00:00

Merge branch 'develop' of https://github.com/boostorg/python into develop

This commit is contained in:
Giuseppe Corbelli
2016-06-27 09:33:44 +02:00
16 changed files with 147 additions and 105 deletions

View File

@@ -10,17 +10,32 @@
language: cpp
env:
- PYTHON=python
- PYTHON=python3
- PYTHON=python CCFLAGS=-std=c++98
- PYTHON=python CCFLAGS=-std=c++11
- PYTHON=python3 CCFLAGS=-std=c++98
- PYTHON=python3 CCFLAGS=-std=c++11
compiler:
- gcc
- gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- clang
- python-dev python-pip
- python3-dev
- libboost-all-dev
before_install:
- sudo apt-get install -y python-dev python-pip
- sudo pip install future
- sudo apt-get install -y python3-dev
- sudo apt-get install -y libboost-all-dev
install:
- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi
script: scons config --python=$PYTHON && scons && scons test

View File

@@ -92,7 +92,7 @@ def prepare_build_dir(env):
def variants(env):
env.Append(CPPPATH = "#/include", CPPDEFINES = ["BOOST_ALL_NO_LIB=1"])
env.Prepend(CPPPATH = "#/include", CPPDEFINES = ["BOOST_ALL_NO_LIB=1"])
set_property(env, architecture = env['TARGET_ARCH'])
for variant in env["variant"]:
e = env.Clone()

View File

@@ -11,10 +11,25 @@ from SCons.Script import Builder
from SCons.Action import Action
from subprocess import check_output, STDOUT, CalledProcessError
import sys
import os
def BoostCompileTest(env, test, source = None, **kw):
def gen_result(target, source, env=env):
target_file = target[0].abspath
result_file = os.path.splitext(target_file)[0] + '.result'
if sys.stdout.isatty():
env['RESULT']='\033[92mPASS\033[0m'
else:
env['RESULT']='PASS'
with open(result_file, 'w+') as result:
result.write('Result: {}\n'.format('pass'))
obj = env.Object(test, source if source is not None else test + '.cpp')
env.AddPostAction(obj, Action(gen_result, cmdstr=None))
env.AddPostAction(obj, Action('@echo $RESULT'))
return obj
def BoostRun(env, prog, target, command = '$SOURCE'):
@@ -77,8 +92,11 @@ def BoostTestSummary(env, tests, **kw):
failures = [r for r in results
if r.get_path().endswith('.result') and not 'Result: pass' in r.get_contents()]
print('%s tests; %s pass; %s fails'%(len(results), len(results)-len(failures), len(failures)))
if failures:
print('For detailed failure reports, see:')
for f in failures:
print('%s\n%s'%(f.get_path(), f.get_contents()))
print(f.get_path())
testsumcomstr = env.get('TESTSUMCOMSTR')
if testsumcomstr:
run = env.Command('summary', tests, Action(print_summary, cmdstr=testsumcomstr))

View File

@@ -70,7 +70,7 @@ namespace detail
template <class T>
inline void assert_castable(boost::type<T>* = 0)
{
typedef char must_be_a_complete_type[sizeof(T)];
typedef char must_be_a_complete_type[sizeof(T)] BOOST_ATTRIBUTE_UNUSED;
}
template <class Source, class Target>

View File

@@ -140,9 +140,9 @@ namespace detail
// https://svn.boost.org/trac/boost/ticket/5803
//typedef typename assertion<mpl::not_<is_same<Default,Fn> > >::failed test0;
# if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407)
typedef typename assertion<is_polymorphic<T> >::failed test1;
typedef typename assertion<is_polymorphic<T> >::failed test1 BOOST_ATTRIBUTE_UNUSED;
# endif
typedef typename assertion<is_member_function_pointer<Fn> >::failed test2;
typedef typename assertion<is_member_function_pointer<Fn> >::failed test2 BOOST_ATTRIBUTE_UNUSED;
not_a_derived_class_member<Default>(Fn());
}
};

View File

@@ -37,7 +37,7 @@ namespace detail
// Must not try to use default implementations except with method definitions.
typedef typename error::multiple_functions_passed_to_def<
Helper::has_default_implementation
>::type assertion;
>::type assertion BOOST_ATTRIBUTE_UNUSED;
detail::scope_setattr_doc(
name, boost::python::make_function(

View File

@@ -135,4 +135,8 @@
#define BOOST_PYTHON_SUPPORTS_PY_SIGNATURES // enables smooth transition
#endif
#if !defined(BOOST_ATTRIBUTE_UNUSED) && defined(__GNUC__) && (__GNUC__ >= 4)
# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
#endif
#endif // CONFIG_DWA052200_H_

View File

@@ -213,7 +213,7 @@ namespace detail
{ \
typedef typename ::boost::python::detail:: \
error::more_keywords_than_function_arguments< \
N,n_args>::too_many_keywords assertion; \
N,n_args>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; \
} \
template <std::size_t N> \
fstubs_name(::boost::python::detail::keywords<N> const& keywords, char const* doc = 0) \
@@ -222,7 +222,7 @@ namespace detail
{ \
typedef typename ::boost::python::detail:: \
error::more_keywords_than_function_arguments< \
N,n_args>::too_many_keywords assertion; \
N,n_args>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; \
}
# if defined(BOOST_NO_VOID_RETURNS)

View File

@@ -68,7 +68,7 @@ namespace detail
template <int keywords, int init_args>
struct more_keywords_than_init_arguments
{
typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1];
typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1] BOOST_ATTRIBUTE_UNUSED;
};
}
@@ -224,7 +224,7 @@ class init : public init_base<init<BOOST_PYTHON_OVERLOAD_ARGS> >
{
typedef typename detail::error::more_keywords_than_init_arguments<
N, n_arguments::value + 1
>::too_many_keywords assertion;
>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED;
}
template <std::size_t N>
@@ -233,7 +233,7 @@ class init : public init_base<init<BOOST_PYTHON_OVERLOAD_ARGS> >
{
typedef typename detail::error::more_keywords_than_init_arguments<
N, n_arguments::value + 1
>::too_many_keywords assertion;
>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED;
}
template <class CallPoliciesT>

View File

@@ -174,7 +174,7 @@ namespace detail
typedef typename detail::error::more_keywords_than_function_arguments<
NumKeywords::value, arity
>::too_many_keywords assertion;
>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED;
typedef typename outer_constructor_signature<Sig>::type outer_signature;

View File

@@ -55,7 +55,7 @@ namespace detail
typedef typename detail::error::more_keywords_than_function_arguments<
NumKeywords::value, arity
>::too_many_keywords assertion;
>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED;
return objects::function_object(
detail::caller<F,CallPolicies,Sig>(f, p)

View File

@@ -107,7 +107,7 @@ namespace detail {
{
typedef typename
error_messages::missing_pickle_suite_function_or_incorrect_signature<
Class_>::error_type error_type;
Class_>::error_type error_type BOOST_ATTRIBUTE_UNUSED;
}
};

View File

@@ -7,12 +7,14 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
import platform
Import('env')
# libs needed for embedding
ELIBS=env['LIBS'] + env['PYTHONLIBS']
def BPLTest(env, name, sources = None, script = None):
def BPLTest(env, name, sources = None, deps = None):
run = env.BoostRunPythonScript(name + '.py')
if sources:
for source in sources:
@@ -21,6 +23,8 @@ def BPLTest(env, name, sources = None, script = None):
)
else:
Depends(run, env.PythonExtension(name + '_ext', name + '.cpp'))
if deps:
Depends(run, deps)
return run
env.AddMethod(BPLTest)
@@ -30,83 +34,81 @@ env.AppendENVPath('PYTHONPATH', Dir('.').path)
tests=[]
tests+=env.BPLTest('crossmod_exception', ['crossmod_exception_a', 'crossmod_exception_b'])
for test in ['injected',
'properties',
'return_arg',
'staticmethod',
'shared_ptr',
'enable_shared_from_this',
'andreas_beyer',
'polymorphism',
'polymorphism2',
'wrapper_held_type',
'polymorphism2_auto_ptr',
'auto_ptr',
'minimal',
'args',
'raw_ctor',
#'numpy',
'exception_translator']:
tests+=env.BPLTest(test)
for test in [('injected',),
('properties',),
('return_arg',),
('staticmethod',),
('shared_ptr',),
('enable_shared_from_this',),
('andreas_beyer',),
('polymorphism',),
('polymorphism2',),
('wrapper_held_type',),
('polymorphism2_auto_ptr',),
('auto_ptr',),
('minimal',),
('args',),
('raw_ctor',),
('numpy',None, ['printer.py', 'numeric_tests.py', 'numarray_tests.py']),
('exception_translator',),
('test_enum', ['enum_ext']),
('test_cltree', ['cltree']),
('newtest', ['m1', 'm2']),
('const_argument',),
('keywords_test', ['keywords']),
('test_pointer_adoption',),
('operators',),
('operators_wrapper',),
('callbacks',),
('defaults',),
('object',),
('list',),
('long',),
('dict',),
('tuple',),
('str',),
('slice',),
('virtual_functions',),
('back_reference',),
('implicit',),
('data_members',),
('ben_scott1',),
('bienstman1',),
('bienstman2',),
('bienstman3',),
('multi_arg_constructor',),
('iterator', ['iterator', 'input_iterator']),
('stl_iterator',),
('extract',),
('crossmod_opaque', ['crossmod_opaque_a', 'crossmod_opaque_b']),
('opaque',),
('voidptr',),
('pickle1',),
('pickle2',),
('pickle3',),
('pickle4',),
('nested',),
('docstring',),
('pytype_function',),
('vector_indexing_suite',),
('pointer_vector',)]:
tests+=env.BPLTest(*test)
tests+=env.BPLTest('test_enum', ['enum_ext'])
tests+=env.BPLTest('test_cltree', ['cltree'])
tests+=env.BPLTest('newtest', ['m1', 'm2'])
tests+=env.BPLTest('const_argument')
tests+=env.BPLTest('keywords_test', ['keywords'])
test = env.BoostRunPythonScript('test_builtin_converters.py')
Depends(
env.BoostRunPythonScript('test_builtin_converters.py'),
env.PythonExtension('builtin_converters_ext', 'test_builtin_converters.cpp')
test,
env.PythonExtension('builtin_converters_ext', ['test_builtin_converters.cpp'])
)
for test in ['test_pointer_adoption',
'operators',
'operators_wrapper',
'callbacks',
'defaults',
'object',
'list',
'long',
'dict',
'tuple',
'str',
'slice',
'virtual_functions',
'back_reference',
'implicit',
'data_members',
'ben_scott1',
'bienstman1',
'bienstman2',
'bienstman3',
'multi_arg_constructor']:
tests+=env.BPLTest(test)
tests+=env.BPLTest('iterator', ['iterator', 'input_iterator'])
tests+=env.BPLTest('stl_iterator')
tests+=env.BPLTest('extract')
tests+=env.BPLTest('crossmod_opaque', ['crossmod_opaque_a', 'crossmod_opaque_b'])
for test in ['opaque',
'voidptr',
'pickle1',
'pickle2',
'pickle3',
'pickle4',
'nested',
'docstring',
'pytype_function',
'vector_indexing_suite',
'pointer_vector']:
tests+=env.BPLTest(test)
tests+=test
test = env.BoostRunPythonScript('map_indexing_suite.py')
Depends(
env.BoostRunPythonScript('map_indexing_suite.py'),
test,
env.PythonExtension('map_indexing_suite_ext', [
'map_indexing_suite.cpp',
'int_map_indexing_suite.cpp',
'a_map_indexing_suite.cpp'])
)
tests+=test
tests+=env.BoostRunTest('import_', 'import_.cpp', '${SOURCES[0]} ${SOURCES[1]}', 'import_.py', LIBS=ELIBS)
@@ -128,5 +130,9 @@ tests+=env.BoostCompileTest('select_holder')
tests+=env.BoostRunTest('select_from_python_test', LIBS=ELIBS)
tests+=env.BoostCompileTest('select_arg_to_python_test')
if platform.system() == 'Windows':
tests+=env.BPLTest('calling_conventions')
tests+=env.BPLTest('calling_conventions_mf')
env.BoostTestSummary(tests)
AlwaysBuild(tests)

View File

@@ -38,7 +38,6 @@ void assert_destructions(int n)
int main()
{
assert_destructions(0);
typedef int a[2];
foo* f1 = new foo;
boost::python::detail::destroy_referent<foo const volatile&>(f1);

View File

@@ -9,11 +9,11 @@ import printer
>>> try: take_array(3)
... except TypeError: pass
... else: print 'expected a TypeError'
... else: print('expected a TypeError')
>>> take_array(x)
>>> print x
>>> print(x)
[[1 2 3]
[4 0 6]
[7 8 9]]

View File

@@ -19,12 +19,12 @@ r"""
>>> def should_pass(method, values):
... result = map(method, values[0])
... if result != values[0]:
... print "Got %s but expected %s" % (result, values[0])
... print("Got %s but expected %s" % (result, values[0]))
>>> def test_overflow(method, values):
... for v in values[1]:
... try: method(v)
... except OverflowError: pass
... else: print "OverflowError expected"
... else: print("OverflowError expected")
# Synthesize idendity functions in case long long not supported
>>> if not 'rewrap_value_long_long' in dir():
@@ -116,7 +116,7 @@ True
>>> for v in _unsigned_values(long_long_size())[1]:
... try: rewrap_value_unsigned_long_long(v)
... except (OverflowError, TypeError): pass
... else: print "OverflowError or TypeError expected"
... else: print("OverflowError or TypeError expected")
>>> assert abs(rewrap_value_float(4.2) - 4.2) < .000001
>>> rewrap_value_double(4.2) - 4.2
@@ -133,12 +133,12 @@ True
>>> rewrap_value_string('yo, wassup?')
'yo, wassup?'
>>> print rewrap_value_wstring(u'yo, wassup?')
>>> print(rewrap_value_wstring(u'yo, wassup?'))
yo, wassup?
test that overloading on unicode works:
>>> print rewrap_value_string(u'yo, wassup?')
>>> print(rewrap_value_string(u'yo, wassup?'))
yo, wassup?
wrap strings with embedded nulls:
@@ -165,7 +165,7 @@ yo, wassup?
>>> try: rewrap_const_reference_bool('yes')
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
>>> rewrap_const_reference_char('x')
'x'
@@ -228,7 +228,7 @@ But None cannot be converted to a string object:
>>> try: rewrap_const_reference_string(None)
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
Now check implicit conversions between floating/integer types
@@ -240,14 +240,14 @@ Now check implicit conversions between floating/integer types
>>> try: rewrap_const_reference_int(42.0)
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
>>> rewrap_value_float(42)
42.0
>>> try: rewrap_value_int(42.0)
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
Check that classic classes also work
@@ -263,19 +263,19 @@ Check that classic classes also work
>>> try: rewrap_const_reference_float(FortyTwo())
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
>>> try: rewrap_value_int(FortyTwo())
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
>>> try: rewrap_const_reference_string(FortyTwo())
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
>>> try: rewrap_value_complex_double(FortyTwo())
... except TypeError: pass
... else: print 'expected a TypeError exception'
... else: print('expected a TypeError exception')
# show that arbitrary handle<T> instantiations can be returned
>>> assert get_type(1) is type(1)