Skip to content

Commit 0dbb780

Browse files
committed
* Updated to new handle_exception() idiom for boost::python
* Made Cygwin archiving reliable, even when the user supplies a path with backslashes ---------------------------------------------------------------------- Modified Files: tools/build/gcc-tools.jam tools/build/new/boost-build.jam boost/python/detail/config.hpp libs/python/build/Jamfile libs/python/example/do_it_yourself_convts.cpp libs/python/example/dvect.cpp libs/python/example/example1.cpp libs/python/example/getting_started1.cpp libs/python/example/getting_started2.cpp libs/python/example/ivect.cpp libs/python/example/nested.cpp libs/python/example/noncopyable_export.cpp libs/python/example/noncopyable_import.cpp libs/python/example/pickle1.cpp libs/python/example/pickle2.cpp libs/python/example/pickle3.cpp libs/python/example/richcmp1.cpp libs/python/example/richcmp2.cpp libs/python/example/richcmp3.cpp libs/python/example/rwgk1.cpp libs/python/example/simple_vector.cpp libs/python/test/comprehensive.cpp Added Files: libs/python/example/rwgk2.cpp libs/python/example/rwgk3.cpp ---------------------------------------------------------------------- [SVN r11705]
1 parent e6efa6e commit 0dbb780

22 files changed

+174
-147
lines changed

build/Jamfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ lib libboost_python_d : ../src/$(CPP_SOURCES).cpp
136136
# Declare a boost python module. Return a list of the DLL files generated.
137137
rule boost-python
138138
{
139-
local debug ;
139+
local debug = "" ;
140140
if ( <define>BOOST_DEBUG_PYTHON in $(3) ) || ( debug-python in $(BUILD) )
141141
{
142142
debug = _d ;
@@ -203,7 +203,9 @@ rule python-test-target # test-target : sources :
203203
{
204204
python-runtest-aux $(<) : $(>) ;
205205
Clean clean : $(<) ; # remove the test-target as part of any clean operation
206-
type-DEPENDS test : $(<) ;
206+
local debug = [ SUBST $(<:B) (_d)$ $1 ] ;
207+
debug ?= "" ;
208+
type-DEPENDS test$(debug) : $(<) ;
207209
MakeLocate $(<) : $(LOCATE_TARGET) ;
208210
}
209211
actions python-test-target bind PYTHON
@@ -249,6 +251,7 @@ rule python-runtest-aux # target : sources
249251
$(gLOCATE($(>[1]))) # location of python test file
250252
$(gRUN_PATH($(<))) # location of module dependencies
251253
[ join-path $(TOP) libs python test ] # location of doctest
254+
$(>:D) # directory of python driver file(s)
252255
$(PYTHONPATH) # base PYTHONPATH from environment
253256
: $(SPLITPATH) ] ; # platform path separator
254257

example/do_it_yourself_convts.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ BOOST_PYTHON_END_CONVERSION_NAMESPACE
107107

108108
BOOST_PYTHON_MODULE_INIT(do_it_yourself_convts)
109109
{
110-
try
111-
{
112110
// Create an object representing this extension module.
113111
python::module_builder this_module("do_it_yourself_convts");
114112

@@ -120,9 +118,4 @@ BOOST_PYTHON_MODULE_INIT(do_it_yourself_convts)
120118
// Add the member functions.
121119
ixset_class.def(&IndexingSet::add, "add");
122120
ixset_class.def(&IndexingSet::get, "get");
123-
}
124-
catch(...)
125-
{
126-
python::handle_exception(); // Deal with the exception for Python
127-
}
128121
}

example/dvect.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ extern "C" void (*old_translator)(unsigned int, EXCEPTION_POINTERS*)
3232

3333
BOOST_PYTHON_MODULE_INIT(dvect)
3434
{
35-
try
36-
{
3735
python::module_builder this_module("dvect");
3836

3937
python::class_builder<vects::dvect> dvect_class(this_module, "dvect");
@@ -47,10 +45,4 @@ BOOST_PYTHON_MODULE_INIT(dvect)
4745

4846
# include "dvect_defs.cpp"
4947
# include "ivect_defs.cpp"
50-
}
51-
catch(...)
52-
{
53-
python::handle_exception(); // Deal with the exception for Python
54-
}
5548
}
56-

example/example1.cpp

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,21 @@ namespace hello {
1616

1717
// Python requires an exported function called init<module-name> in every
1818
// extension module. This is where we build the module contents.
19-
extern "C"
20-
#ifdef _WIN32
21-
__declspec(dllexport)
22-
#endif
23-
void inithello()
19+
BOOST_PYTHON_MODULE_INIT(hello)
2420
{
25-
try
26-
{
27-
// create an object representing this extension module
28-
boost::python::module_builder hello("hello");
29-
30-
// Create the Python type object for our extension class
31-
boost::python::class_builder<hello::world> world_class(hello, "world");
32-
33-
// Add the __init__ function
34-
world_class.def(boost::python::constructor<int>());
35-
// Add a regular member function
36-
world_class.def(&hello::world::get, "get");
37-
38-
// Add a regular function to the module
39-
hello.def(hello::length, "length");
40-
}
41-
catch(...)
42-
{
43-
boost::python::handle_exception(); // Deal with the exception for Python
44-
}
21+
// create an object representing this extension module
22+
boost::python::module_builder hello("hello");
23+
24+
// Create the Python type object for our extension class
25+
boost::python::class_builder<hello::world> world_class(hello, "world");
26+
27+
// Add the __init__ function
28+
world_class.def(boost::python::constructor<int>());
29+
// Add a regular member function
30+
world_class.def(&hello::world::get, "get");
31+
32+
// Add a regular function to the module
33+
hello.def(hello::length, "length");
4534
}
4635

4736
// Win32 DLL boilerplate

example/getting_started1.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,10 @@ namespace python = boost::python;
1616
// extension module. This is where we build the module contents.
1717
BOOST_PYTHON_MODULE_INIT(getting_started1)
1818
{
19-
try
20-
{
2119
// Create an object representing this extension module.
2220
python::module_builder this_module("getting_started1");
2321

2422
// Add regular functions to the module.
2523
this_module.def(greet, "greet");
2624
this_module.def(square, "square");
27-
}
28-
catch(...)
29-
{
30-
python::handle_exception(); // Deal with the exception for Python
31-
}
3225
}

example/getting_started2.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ namespace python = boost::python;
2626

2727
BOOST_PYTHON_MODULE_INIT(getting_started2)
2828
{
29-
try
30-
{
3129
// Create an object representing this extension module.
3230
python::module_builder this_module("getting_started2");
3331

@@ -44,9 +42,4 @@ BOOST_PYTHON_MODULE_INIT(getting_started2)
4442

4543
// Even better, invite() can also be made a member of hello_class!!!
4644
hello_class.def(invite, "invite");
47-
}
48-
catch(...)
49-
{
50-
python::handle_exception(); // Deal with the exception for Python
51-
}
5245
}

example/ivect.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ extern "C" void (*old_translator)(unsigned int, EXCEPTION_POINTERS*)
3232

3333
BOOST_PYTHON_MODULE_INIT(ivect)
3434
{
35-
try
36-
{
3735
python::module_builder this_module("ivect");
3836

3937
python::class_builder<vects::ivect> ivect_class(this_module, "ivect");
@@ -47,10 +45,5 @@ BOOST_PYTHON_MODULE_INIT(ivect)
4745

4846
# include "dvect_defs.cpp"
4947
# include "ivect_defs.cpp"
50-
}
51-
catch(...)
52-
{
53-
python::handle_exception(); // Deal with the exception for Python
54-
}
5548
}
5649

example/nested.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ namespace {
3232

3333
BOOST_PYTHON_MODULE_INIT(nested)
3434
{
35-
try
36-
{
3735
boost::python::module_builder this_module("nested");
3836
this_module.def(show_nested_tuples, "show_nested_tuples");
39-
}
40-
catch(...)
41-
{
42-
boost::python::handle_exception();
43-
}
4437
}

example/noncopyable_export.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,11 @@ extern "C" void (*old_translator)(unsigned int, EXCEPTION_POINTERS*)
1818

1919
BOOST_PYTHON_MODULE_INIT(noncopyable_export)
2020
{
21-
try
22-
{
2321
python::module_builder this_module("noncopyable_export");
2422

2523
python::class_builder<store> store_class(this_module, "store");
2624
python::export_converters_noncopyable(store_class);
2725

2826
store_class.def(python::constructor<int>());
2927
store_class.def(&store::recall, "recall");
30-
}
31-
catch(...)
32-
{
33-
python::handle_exception(); // Deal with the exception for Python
34-
}
3528
}

example/noncopyable_import.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ extern "C" void (*old_translator)(unsigned int, EXCEPTION_POINTERS*)
3131

3232
BOOST_PYTHON_MODULE_INIT(noncopyable_import)
3333
{
34-
try
35-
{
3634
python::module_builder this_module("noncopyable_import");
3735

3836
python::import_converters<store>
@@ -44,9 +42,4 @@ BOOST_PYTHON_MODULE_INIT(noncopyable_import)
4442
// However, to keep this example simple, we only define a
4543
// module-level function.
4644
this_module.def(add_stores, "add_stores");
47-
}
48-
catch(...)
49-
{
50-
python::handle_exception(); // Deal with the exception for Python
51-
}
5245
}

0 commit comments

Comments
 (0)