@@ -8,11 +8,19 @@ \chapter{Exception Handling \label{exceptionHandling}}
88this on success, but will set it to indicate the cause of the error on
99failure. 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
1415generally 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
1725The error indicator consists of three Python objects corresponding to
1826\withsubitem {(in module sys)}{
0 commit comments