boost/boost-1.55.0-python-test-PyImport_AppendInittab.patch
Marcus Rueckert 9d48e24b64 Accepting request 449886 from home:adamm:branches:devel:libraries:c_c++
- update to version 1.63.0
  * updated libraries: atomic, container, context, fiber,
    fusion, geometry, hash, interprocess, intrusive, lexical cast,
    log, metaparse, move, optional, phoenix, python, test,
    typeindex, units, unordered
  * see http://www.boost.org/users/history/version_1_63_0.html
    for complete list of changes
- refresh patches
  * boost-1.55.0-python-test-PyImport_AppendInittab.patch
  * boost-strict_aliasing.patch, and enable -fno-strict-aliasing
    for python module
- baselibs.conf:
  * add libboost_locale
  * rename python to include new soname
- remove python-2059618.patch, not needed
- make build condition --without buil_mpi work
- allow building without python3 bindings, for SLE11SP4
- remove versioned build dependency on libicu-devel, apparently
  not needed.
- split out the boost-devel package into individudal compiled
  libraries and their -devel subpackages and libboost_headers-devel
  package for header-only libraries.
- remove all the -mt.so symlinks, probably not needed anymore.
- ship MPI python bindings for both Python 2.7 and 3.x

OBS-URL: https://build.opensuse.org/request/show/449886
OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/boost?expand=0&rev=182
2017-01-13 14:53:30 +00:00

88 lines
2.2 KiB
Diff

Index: boost_1_63_0/libs/python/test/exec.cpp
===================================================================
--- boost_1_63_0.orig/libs/python/test/exec.cpp
+++ boost_1_63_0/libs/python/test/exec.cpp
@@ -56,8 +56,24 @@ void eval_test()
BOOST_TEST(value == "ABCDEFG");
}
+struct PyCtx
+{
+ PyCtx() {
+ Py_Initialize();
+ }
+
+ ~PyCtx() {
+ // N.B. certain problems may arise when Py_Finalize is called when
+ // using Boost.Python. However in this test suite it all seems to
+ // work fine.
+ Py_Finalize();
+ }
+};
+
void exec_test()
{
+ PyCtx ctx;
+
// Retrieve the main module
python::object main = python::import("__main__");
@@ -138,6 +154,19 @@ void check_pyerr(bool pyerr_expected=fal
}
}
+template <class Cb>
+bool
+run_and_handle_exception(Cb cb, bool pyerr_expected = false)
+{
+ PyCtx ctx;
+ if (python::handle_exception(cb)) {
+ check_pyerr(pyerr_expected);
+ return true;
+ } else {
+ return false;
+ }
+}
+
int main(int argc, char **argv)
{
BOOST_TEST(argc == 2 || argc == 3);
@@ -156,29 +185,19 @@ int main(int argc, char **argv)
"builtin modules");
}
- // Initialize the interpreter
- Py_Initialize();
-
- if (python::handle_exception(eval_test)) {
+ // N.B. exec_test mustn't be called through run_and_handle_exception
+ // as it needs to handles the python context by itself.
+ if (run_and_handle_exception(eval_test)
+ || python::handle_exception(exec_test))
check_pyerr();
- }
- else if(python::handle_exception(exec_test)) {
- check_pyerr();
- }
- else if (python::handle_exception(boost::bind(exec_file_test, script))) {
- check_pyerr();
- }
-
- if (python::handle_exception(exec_test_error))
- {
- check_pyerr(/*pyerr_expected*/ true);
- }
else
- {
+ run_and_handle_exception(boost::bind(exec_file_test, script));
+
+ if (!run_and_handle_exception(exec_test_error, true))
BOOST_ERROR("Python exception expected, but not seen.");
- }
if (argc > 2) {
+ PyCtx ctx;
// The main purpose is to test compilation. Since this test generates
// a file and I (rwgk) am uncertain about the side-effects, run it only
// if explicitly requested.