.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Python::Err 3"
.TH Python::Err 3 "2021-04-27" "perl v5.32.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Python::Err \- Python exception objects
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 7
\& # 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");
\& }
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Python exceptions are wrapped up in \f(CW\*(C`Python::Err\*(C'\fR objects. If perl
calls some python function and this function raise an exception then
$@ will end up as a reference to a \f(CW\*(C`Python::Err\*(C'\fR object.
.PP
The following methods are available:
.ie n .IP "$err\->type" 4
.el .IP "\f(CW$err\fR\->type" 4
.IX Item "$err->type"
What kind of exception this is. It should usually be a reference to
one of exception type objects described below.
.ie n .IP "$err\->value" 4
.el .IP "\f(CW$err\fR\->value" 4
.IX Item "$err->value"
An assosiated value, usually just a human readable string explaining
the reason for the failure.
.ie n .IP "$err\->traceback" 4
.el .IP "\f(CW$err\fR\->traceback" 4
.IX Item "$err->traceback"
The traceback object contain stack trace information from the location
where the exceptions where raised and down.
.ie n .IP "$err\->as_string" 4
.el .IP "\f(CW$err\fR\->as_string" 4
.IX Item "$err->as_string"
Overloaded stringify. Allow python exceptions to be matched using
regular expressions on $@ and to be printed. Exceptions are
stringified as:
.Sp
.Vb 1
\& "$type: $value"
.Ve
.ie n .IP "$err\->as_bool" 4
.el .IP "\f(CW$err\fR\->as_bool" 4
.IX Item "$err->as_bool"
Overloaded for boolean tests and will always return \s-1TRUE,\s0 so it is not
actually very useful :\-)
.PP
If perl code is known to be invoked from python code, then it might
want to raise native python exceptions.
.ie n .IP "Python::raise($type, $value)" 4
.el .IP "Python::raise($type, \f(CW$value\fR)" 4
.IX Item "Python::raise($type, $value)"
The \fBraise()\fR function will raise a python exception of the given
\&\fItype\fR and pass with it the given \fIvalue\fR.
.SS "Standard exception type objects"
.IX Subsection "Standard exception type objects"
References to all the standard python exception type objects can be
obtained using the following names.
.IP "Python::Err::Exception" 4
.IX Item "Python::Err::Exception"
The root class for all exceptions.
.IP "Python::Err::StandardError" 4
.IX Item "Python::Err::StandardError"
The base class for all built-in exceptions.
.IP "Python::Err::ArithmeticError" 4
.IX Item "Python::Err::ArithmeticError"
The base class for all arithmentic exceptions.
.IP "Python::Err::LookupError" 4
.IX Item "Python::Err::LookupError"
The base class for indexing and key exceptions.
.IP "Python::Err::AssertionError" 4
.IX Item "Python::Err::AssertionError"
Failed assert statement.
.IP "Python::Err::AttributeError" 4
.IX Item "Python::Err::AttributeError"
Failed attribute reference or asssignment
.IP "Python::Err::EOFError" 4
.IX Item "Python::Err::EOFError"
End of file.
.IP "Python::Err::FloatingPointError" 4
.IX Item "Python::Err::FloatingPointError"
.PD 0
.IP "Python::Err::EnvironmentError" 4
.IX Item "Python::Err::EnvironmentError"
.PD
Base class for errors that occur outside Python.
.IP "Python::Err::IOError" 4
.IX Item "Python::Err::IOError"
Failed I/O operation.
.IP "Python::Err::OSError" 4
.IX Item "Python::Err::OSError"
.PD 0
.IP "Python::Err::ImportError" 4
.IX Item "Python::Err::ImportError"
.IP "Python::Err::IndexError" 4
.IX Item "Python::Err::IndexError"
.IP "Python::Err::KeyError" 4
.IX Item "Python::Err::KeyError"
.IP "Python::Err::KeyboardInterrupt" 4
.IX Item "Python::Err::KeyboardInterrupt"
.IP "Python::Err::MemoryError" 4
.IX Item "Python::Err::MemoryError"
.IP "Python::Err::NameError" 4
.IX Item "Python::Err::NameError"
.IP "Python::Err::OverflowError" 4
.IX Item "Python::Err::OverflowError"
.IP "Python::Err::RuntimeError" 4
.IX Item "Python::Err::RuntimeError"
.IP "Python::Err::NotImplementedError" 4
.IX Item "Python::Err::NotImplementedError"
.IP "Python::Err::SyntaxError" 4
.IX Item "Python::Err::SyntaxError"
.IP "Python::Err::SystemError" 4
.IX Item "Python::Err::SystemError"
.IP "Python::Err::SystemExit" 4
.IX Item "Python::Err::SystemExit"
.IP "Python::Err::TypeError" 4
.IX Item "Python::Err::TypeError"
.IP "Python::Err::UnboundLocalError" 4
.IX Item "Python::Err::UnboundLocalError"
.IP "Python::Err::UnicodeError" 4
.IX Item "Python::Err::UnicodeError"
.IP "Python::Err::ValueError" 4
.IX Item "Python::Err::ValueError"
.IP "Python::Err::ZeroDivisionError" 4
.IX Item "Python::Err::ZeroDivisionError"
.PD
.PP
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.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
(C) 2000\-2001 ActiveState
.PP
This code is distributed under the same terms as Perl; you can
redistribute it and/or modify it under the terms of either the \s-1GNU\s0
General Public License or the Artistic License.
.PP
\&\s-1THIS SOFTWARE IS PROVIDED BY ACTIVESTATE\s0 `\s-1AS IS\s0'' \s-1AND ANY EXPRESSED OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.\s0 \s-1IN NO EVENT SHALL ACTIVESTATE OR ITS CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES\s0 (\s-1INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES\s0; \s-1LOSS OF USE, DATA, OR PROFITS\s0; \s-1OR
BUSINESS INTERRUPTION\s0) \s-1HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\s0 (\s-1INCLUDING NEGLIGENCE
OR OTHERWISE\s0) \s-1ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\s0
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Python::Object, Python, perlmodule