From e9caacc428da1bcd43f7212b4056956b6838103f Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Fri, 18 May 2007 15:52:55 +0000 Subject: [PATCH] More fixes for embedding python docs. [SVN r37709] --- doc/tutorial/doc/html/index.html | 6 ++-- doc/tutorial/doc/html/python/embedding.html | 38 +++++---------------- doc/tutorial/doc/html/python/exposing.html | 4 +-- doc/tutorial/doc/html/python/functions.html | 10 +++--- doc/tutorial/doc/html/python/hello.html | 6 ++-- doc/tutorial/doc/html/python/object.html | 2 +- doc/tutorial/doc/tutorial.qbk | 26 +++----------- 7 files changed, 27 insertions(+), 65 deletions(-) diff --git a/doc/tutorial/doc/html/index.html b/doc/tutorial/doc/html/index.html index ebee7e2a..5188c77f 100644 --- a/doc/tutorial/doc/html/index.html +++ b/doc/tutorial/doc/html/index.html @@ -31,7 +31,7 @@
-

+

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt ) @@ -94,7 +94,7 @@ (IDL).

- + Hello World

@@ -145,7 +145,7 @@

- +

Last revised: May 17, 2007 at 14:24:30 GMT

Last revised: May 18, 2007 at 15:46:01 GMT


diff --git a/doc/tutorial/doc/html/python/embedding.html b/doc/tutorial/doc/html/python/embedding.html index 10e5b13a..7e8250d8 100644 --- a/doc/tutorial/doc/html/python/embedding.html +++ b/doc/tutorial/doc/html/python/embedding.html @@ -40,7 +40,7 @@ Python/C API at all. So stay tuned... smiley

- + Building embedded programs

@@ -82,7 +82,7 @@ exe embedded_program # name of the executable <find-library>$(PYTHON_EMBEDDED_LIBRARY) ;

- + Getting started

@@ -137,7 +137,7 @@ exe embedded_program # name of the executable automate the process.

- + Running Python code

@@ -188,7 +188,7 @@ exe embedded_program # name of the executable a phrase that is well-known in programming circles.

- + Manipulating Python objects

@@ -215,15 +215,12 @@ exe embedded_program # name of the executable int five_squared = extract<int>(result);

- + Exception handling

- If an exception occurs in the execution of some Python code, the PyRun_String - function returns a null pointer. Constructing a handle - out of this null pointer throws error_already_set, - so basically, the Python exception is automatically translated into a C++ - exception when using handle: + If an exception occurs in the evaluation of the python expression, error_already_set + is thrown:

 try
@@ -232,7 +229,7 @@ exe embedded_program # name of the executable
     // execution will never get here:
     int five_divided_by_zero = extract<int>(result);
 }
-catch(error_already_set)
+catch(error_already_set const &)
 {
     // handle the exception in some way
 }
@@ -248,7 +245,7 @@ exe embedded_program # name of the executable
         exceptions:
       

-catch(error_already_set)
+catch(error_already_set const &)
 {
     if (PyErr_ExceptionMatches(PyExc_ZeroDivisionError))
     {
@@ -265,23 +262,6 @@ exe embedded_program # name of the executable
         (To retrieve even more information from the exception you can use some of
         the other exception handling functions listed here.)
       

-

- If you'd rather not have handle throw a C++ exception - when it is constructed, you can use the allow_null - function in the same way you'd use borrowed: -

-
-handle<> result((allow_null(PyRun_String(
-    "5/0"
-   , Py_eval_input
-   , main_namespace.ptr()
-   , main_namespace.ptr()))));
-
-if (!result)
-    // Python exception occurred
-else
-    // everything went okay, it's safe to use the result
-
diff --git a/doc/tutorial/doc/html/python/exposing.html b/doc/tutorial/doc/html/python/exposing.html index 0af4aa15..3f3f1888 100644 --- a/doc/tutorial/doc/html/python/exposing.html +++ b/doc/tutorial/doc/html/python/exposing.html @@ -519,7 +519,7 @@

Class Operators/Special Functions

- + Python Operators

@@ -568,7 +568,7 @@ expressions".

- + Special Methods

diff --git a/doc/tutorial/doc/html/python/functions.html b/doc/tutorial/doc/html/python/functions.html index 250bf8a4..927863d4 100644 --- a/doc/tutorial/doc/html/python/functions.html +++ b/doc/tutorial/doc/html/python/functions.html @@ -212,7 +212,7 @@ Namespaces are one honking great idea -- let's do more of those!

  • BOOM!
  • - + Call Policies

    @@ -411,7 +411,7 @@ Namespaces are one honking great idea -- let's do more of those!

    - + BOOST_PYTHON_FUNCTION_OVERLOADS

    @@ -441,7 +441,7 @@ Namespaces are one honking great idea -- let's do more of those! def("foo", foo, foo_overloads());

    - + BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS

    @@ -487,7 +487,7 @@ Namespaces are one honking great idea -- let's do more of those! reference for details.

    - + init and optional

    @@ -561,7 +561,7 @@ Namespaces are one honking great idea -- let's do more of those! (0) arguments and a maximum of 3 arguments.

    - + Manual Wrapping

    diff --git a/doc/tutorial/doc/html/python/hello.html b/doc/tutorial/doc/html/python/hello.html index 0a130dc2..062e5c29 100644 --- a/doc/tutorial/doc/html/python/hello.html +++ b/doc/tutorial/doc/html/python/hello.html @@ -26,7 +26,7 @@

    Building Hello World

    - + From Start To Finish

    @@ -101,7 +101,7 @@ platforms. The complete list of Bjam executables can be found here.

    - + Let's Jam!

    @@ -152,7 +152,7 @@ extension hello # Declare a Python extension called hello The last part tells BJam that we are depending on the Boost Python Library.

    - + Running bjam

    diff --git a/doc/tutorial/doc/html/python/object.html b/doc/tutorial/doc/html/python/object.html index da170867..e198cca7 100644 --- a/doc/tutorial/doc/html/python/object.html +++ b/doc/tutorial/doc/html/python/object.html @@ -199,7 +199,7 @@ d['whatever'] = 3; // modifies the copy

    - + class_<T> as objects

    diff --git a/doc/tutorial/doc/tutorial.qbk b/doc/tutorial/doc/tutorial.qbk index f5cb2ed8..13a2222a 100644 --- a/doc/tutorial/doc/tutorial.qbk +++ b/doc/tutorial/doc/tutorial.qbk @@ -1520,11 +1520,8 @@ which returns the result directly: [h2 Exception handling] -If an exception occurs in the execution of some Python code, the PyRun_String -function returns a null pointer. Constructing a [^handle] out of this null -pointer throws [@../../../v2/errors.html#error_already_set-spec error_already_set], -so basically, the Python exception is automatically translated into a -C++ exception when using [^handle]: +If an exception occurs in the evaluation of the python expression, +[@../../../v2/errors.html#error_already_set-spec error_already_set] is thrown: try { @@ -1532,7 +1529,7 @@ C++ exception when using [^handle]: // execution will never get here: int five_divided_by_zero = extract(result); } - catch(error_already_set) + catch(error_already_set const &) { // handle the exception in some way } @@ -1546,7 +1543,7 @@ print the exception's traceback to the console, or comparing the type of the exception with those of the [@http://www.python.org/doc/api/standardExceptions.html standard exceptions]: - catch(error_already_set) + catch(error_already_set const &) { if (PyErr_ExceptionMatches(PyExc_ZeroDivisionError)) { @@ -1562,21 +1559,6 @@ standard exceptions]: (To retrieve even more information from the exception you can use some of the other exception handling functions listed [@http://www.python.org/doc/api/exceptionHandling.html here].) -If you'd rather not have [^handle] throw a C++ exception when it is constructed, you -can use the [@../../../v2/handle.html#allow_null-spec allow_null] function in the same -way you'd use borrowed: - - handle<> result((allow_null(PyRun_String( - "5/0" - , Py_eval_input - , main_namespace.ptr() - , main_namespace.ptr())))); - - if (!result) - // Python exception occurred - else - // everything went okay, it's safe to use the result - [endsect] [endsect] [/ Embedding]