From 93735c7bf1538572018fedae9c76b05f46298d12 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 8 Feb 2002 22:04:01 +0000 Subject: [PATCH] Updated docs and provided backwards compatibility for handle_exception() [SVN r12764] --- doc/example1.html | 7 ------- doc/exporting_classes.html | 7 ------- doc/inheritance.html | 33 +++++++++++++-------------------- doc/overriding.html | 13 +++---------- example/getting_started1.cpp | 5 +++++ 5 files changed, 21 insertions(+), 44 deletions(-) diff --git a/doc/example1.html b/doc/example1.html index 402cc7a6..ee01e72c 100644 --- a/doc/example1.html +++ b/doc/example1.html @@ -37,19 +37,12 @@ namespace python = boost::python; BOOST_PYTHON_MODULE_INIT(getting_started1) { - try - { // Create an object representing this extension module. python::module_builder this_module("getting_started1"); // Add regular functions to the module. this_module.def(greet, "greet"); this_module.def(square, "square"); - } - catch(...) - { - python::handle_exception(); // Deal with the exception for Python - } } diff --git a/doc/exporting_classes.html b/doc/exporting_classes.html index 61c5ef88..cbeb8a9e 100644 --- a/doc/exporting_classes.html +++ b/doc/exporting_classes.html @@ -47,8 +47,6 @@ namespace python = boost::python; BOOST_PYTHON_MODULE_INIT(getting_started2) { - try - { // Create an object representing this extension module. python::module_builder this_module("getting_started2"); @@ -65,11 +63,6 @@ BOOST_PYTHON_MODULE_INIT(getting_started2) // Even better, invite() can also be made a member of hello_class!!! hello_class.def(invite, "invite"); - } - catch(...) - { - python::handle_exception(); // Deal with the exception for Python - } }

diff --git a/doc/inheritance.html b/doc/inheritance.html index cd95c744..3cceb0d0 100644 --- a/doc/inheritance.html +++ b/doc/inheritance.html @@ -78,26 +78,19 @@ namespace python = boost::python; BOOST_PYTHON_MODULE_INIT(my_module) { -    try -    { -       python::module_builder my_module("my_module"); - -       python::class_builder<Base> base_class(my_module, "Base"); -       base_class.def(python::constructor<void>()); - -       python::class_builder<Derived> derived_class(my_module, "Derived"); -       derived_class.def(python::constructor<void>()); - // Establish the inheritance relationship between Base and Derived - derived_class.declare_base(base_class); - - my_module.def(derived_as_base, "derived_as_base"); - my_module.def(get_name, "get_name"); - my_module.def(get_derived_x, "get_derived_x"); -    } -    catch(...) -    { -       python::handle_exception();    // Deal with the exception for Python -    } +    python::module_builder my_module("my_module"); + +    python::class_builder<Base> base_class(my_module, "Base"); +    base_class.def(python::constructor<void>()); + +    python::class_builder<Derived> derived_class(my_module, "Derived"); +    derived_class.def(python::constructor<void>()); + // Establish the inheritance relationship between Base and Derived + derived_class.declare_base(base_class); + + my_module.def(derived_as_base, "derived_as_base"); + my_module.def(get_name, "get_name"); + my_module.def(get_derived_x, "get_derived_x"); } diff --git a/doc/overriding.html b/doc/overriding.html index 02665be5..085d5a7f 100644 --- a/doc/overriding.html +++ b/doc/overriding.html @@ -151,16 +151,9 @@ struct baz_callback { BOOST_PYTHON_MODULE_INIT(foobar) { - try - { - boost::python::module_builder foobar("foobar"); - boost::python::class_builder<baz,baz_callback> baz_class("baz"); - baz_class.def(&baz::calls_pure, "calls_pure"); - } - catch(...) - { - boost::python::handle_exception(); // Deal with the exception for Python - } + boost::python::module_builder foobar("foobar"); + boost::python::class_builder<baz,baz_callback> baz_class("baz"); + baz_class.def(&baz::calls_pure, "calls_pure"); } diff --git a/example/getting_started1.cpp b/example/getting_started1.cpp index 2f180633..91a1f551 100644 --- a/example/getting_started1.cpp +++ b/example/getting_started1.cpp @@ -16,10 +16,15 @@ namespace python = boost::python; // extension module. This is where we build the module contents. BOOST_PYTHON_MODULE_INIT(getting_started1) { + try { // Create an object representing this extension module. python::module_builder this_module("getting_started1"); // Add regular functions to the module. this_module.def(greet, "greet"); this_module.def(square, "square"); + } + catch(...) { + boost::python::handle_exception(); + } }