Skip to content

Commit 93735c7

Browse files
committed
Updated docs and provided backwards compatibility for handle_exception()
[SVN r12764]
1 parent e37a97e commit 93735c7

5 files changed

Lines changed: 21 additions & 44 deletions

File tree

doc/example1.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,12 @@ <h1>
3737

3838
BOOST_PYTHON_MODULE_INIT(getting_started1)
3939
{
40-
try
41-
{
4240
// Create an object representing this extension module.
4341
python::module_builder this_module("getting_started1");
4442

4543
// Add regular functions to the module.
4644
this_module.def(greet, "greet");
4745
this_module.def(square, "square");
48-
}
49-
catch(...)
50-
{
51-
python::handle_exception(); // Deal with the exception for Python
52-
}
5346
}
5447
</pre>
5548
</blockquote>

doc/exporting_classes.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ <h1>
4747

4848
BOOST_PYTHON_MODULE_INIT(getting_started2)
4949
{
50-
try
51-
{
5250
// Create an object representing this extension module.
5351
python::module_builder this_module("getting_started2");
5452

@@ -65,11 +63,6 @@ <h1>
6563

6664
// Even better, invite() can also be made a member of hello_class!!!
6765
hello_class.def(invite, "invite");
68-
}
69-
catch(...)
70-
{
71-
python::handle_exception(); // Deal with the exception for Python
72-
}
7366
}
7467
</blockquote></pre>
7568
<p>

doc/inheritance.html

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,19 @@ <h2><a name="implicit_conversion">Reflecting C++ Inheritance Relationships</a></
7878

7979
BOOST_PYTHON_MODULE_INIT(my_module)
8080
{
81-
    try
82-
    {
83-
       python::module_builder my_module("my_module");
84-
85-
       python::class_builder&lt;Base&gt; base_class(my_module, "Base");
86-
       base_class.def(python::constructor&lt;void&gt;());
87-
88-
       python::class_builder&lt;Derived&gt; derived_class(my_module, "Derived");
89-
       derived_class.def(python::constructor&lt;void&gt;());
90-
<b>// Establish the inheritance relationship between Base and Derived
91-
derived_class.declare_base(base_class);</b>
92-
93-
my_module.def(derived_as_base, "derived_as_base");
94-
my_module.def(get_name, "get_name");
95-
my_module.def(get_derived_x, "get_derived_x");
96-
    }
97-
    catch(...)
98-
    {
99-
       python::handle_exception();    // Deal with the exception for Python
100-
    }
81+
    python::module_builder my_module("my_module");
82+
83+
    python::class_builder&lt;Base&gt; base_class(my_module, "Base");
84+
    base_class.def(python::constructor&lt;void&gt;());
85+
86+
    python::class_builder&lt;Derived&gt; derived_class(my_module, "Derived");
87+
    derived_class.def(python::constructor&lt;void&gt;());
88+
<b>// Establish the inheritance relationship between Base and Derived
89+
derived_class.declare_base(base_class);</b>
90+
91+
my_module.def(derived_as_base, "derived_as_base");
92+
my_module.def(get_name, "get_name");
93+
my_module.def(get_derived_x, "get_derived_x");
10194
}
10295
</pre>
10396
</blockquote>

doc/overriding.html

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,9 @@ <h2>Pure Virtual Functions</h2>
151151

152152
BOOST_PYTHON_MODULE_INIT(foobar)
153153
{
154-
try
155-
{
156-
boost::python::module_builder foobar("foobar");
157-
boost::python::class_builder&lt;baz,baz_callback&gt; baz_class("baz");
158-
baz_class.def(&amp;baz::calls_pure, "calls_pure");
159-
}
160-
catch(...)
161-
{
162-
boost::python::handle_exception(); // Deal with the exception for Python
163-
}
154+
boost::python::module_builder foobar("foobar");
155+
boost::python::class_builder&lt;baz,baz_callback&gt; baz_class("baz");
156+
baz_class.def(&amp;baz::calls_pure, "calls_pure");
164157
}
165158
</pre>
166159
</blockquote>

example/getting_started1.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ 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 {
1920
// Create an object representing this extension module.
2021
python::module_builder this_module("getting_started1");
2122

2223
// Add regular functions to the module.
2324
this_module.def(greet, "greet");
2425
this_module.def(square, "square");
26+
}
27+
catch(...) {
28+
boost::python::handle_exception();
29+
}
2530
}

0 commit comments

Comments
 (0)