Python::Err - Python exception objects |
Python::Err - Python exception objects
# catching eval { .... } if ($@ && UNIVERSAL::iso("Python::Err")) { # deal with the exception }
# raising if (... arg is not as expected ...) { Python:Err->Raise(Python::Err::TypeError, "a foo object expected"); }
Python exceptions are wrapped up in Python::Err
objects. If perl
calls some python function and this function raise an exception then
$@ will end up as a reference to a Python::Err
object.
The following methods are available:
"$type: $value"
If perl code is known to be invoked from python code, then it might want to raise native python exceptions.
raise()
function will raise a python exception of the given
type and pass with it the given value.
References to all the standard python exception type objects can be obtained using the following names.
If these functions are called with a single argument then they test if the object passed in is of the given type. The argument can be either a Python exception object or a Python::Err object. The test test does not yet consider inheritance of exceptions.
(C) 2000-2001 ActiveState
This code is distributed under the same terms as Perl; you can redistribute it and/or modify it under the terms of either the GNU General Public License or the Artistic License.
THIS SOFTWARE IS PROVIDED BY ACTIVESTATE `AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ACTIVESTATE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
the Python::Object manpage, the Python manpage, perlmodule
Python::Err - Python exception objects |