2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 06:02:14 +00:00

libs/python/build/Jamfile.v2: remove needless <define> property.

libs/python/test/Jamfile.v2:
  * add dynamically-linked embedding test

  * fix builtin_converters test so it can work (BBv1 allowed the
    duplication of main target names; BBv2 does not)


libs/python/test/import_.cpp: move some more of the Python code within
  a handle_exception callback so at least we can better diagnose
  failures.


[SVN r37214]
This commit is contained in:
Dave Abrahams
2007-03-17 20:17:56 +00:00
parent e61401d27e
commit 44d53c448b
3 changed files with 29 additions and 29 deletions

View File

@@ -4,15 +4,28 @@
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/python.hpp>
#include <boost/bind.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <iostream>
#include <sstream>
namespace bpl = boost::python;
void import_test()
void import_test( char** argv )
{
// Retrieve the main module
bpl::object main = bpl::import("__main__");
// Retrieve the main module's namespace
bpl::object global(main.attr("__dict__"));
// Inject search path for import_ module
std::ostringstream script;
script << "import sys, os\n"
<< "path = os.path.dirname('" << argv[1] << "')\n"
<< "sys.path.insert(0, path)\n";
bpl::exec(bpl::str(script.str()), global, global);
// Retrieve the main module
bpl::object import_ = bpl::import("import_");
int value = bpl::extract<int>(import_.attr("value")) BOOST_EXTRACT_WORKAROUND;
@@ -27,19 +40,7 @@ int main(int argc, char **argv)
// Initialize the interpreter
Py_Initialize();
// Retrieve the main module
bpl::object main = bpl::import("__main__");
// Retrieve the main module's namespace
bpl::object global(main.attr("__dict__"));
// Inject search path for import_ module
std::ostringstream script;
script << "import sys, os.path\n"
<< "path = os.path.dirname('" << argv[1] << "')\n"
<< "sys.path.insert(0, path)\n";
bpl::object result = bpl::exec(bpl::str(script.str()), global, global);
if (bpl::handle_exception(import_test))
if (bpl::handle_exception(boost::bind(import_test, argv)))
{
if (PyErr_Occurred())
{