Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 551ffae

Browse files
committed
Clarify that the Python runtime may behave mysteriously when an exception
is not handled properly. This closes SF bug #485153.
1 parent 3570551 commit 551ffae

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

Doc/api/exceptions.tex

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ \chapter{Exception Handling \label{exceptionHandling}}
88
this on success, but will set it to indicate the cause of the error on
99
failure. Most functions also return an error indicator, usually
1010
\NULL{} if they are supposed to return a pointer, or \code{-1} if they
11-
return an integer (exception: the \cfunction{PyArg_Parse*()} functions
12-
return \code{1} for success and \code{0} for failure). When a
13-
function must fail because some function it called failed, it
11+
return an integer (exception: the \cfunction{PyArg_*()} functions
12+
return \code{1} for success and \code{0} for failure).
13+
14+
When a function must fail because some function it called failed, it
1415
generally doesn't set the error indicator; the function it called
15-
already set it.
16+
already set it. It is responsible for either handling the error and
17+
clearing the exception or returning after cleaning up any resources it
18+
holds (such as object references or memory allocations); it should
19+
\emph{not} continue normally if it is not prepared to handle the
20+
error. If returning due to an error, it is important to indicate to
21+
the caller that an error has been set. If the error is not handled or
22+
carefully propogated, additional calls into the Python/C API may not
23+
behave as intended and may fail in mysterious ways.
1624

1725
The error indicator consists of three Python objects corresponding to
1826
\withsubitem{(in module sys)}{

0 commit comments

Comments
 (0)