]> granicus.if.org Git - python/commit
Simplify and fix error handling for most cases.
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 16 Oct 2001 23:02:32 +0000 (23:02 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 16 Oct 2001 23:02:32 +0000 (23:02 +0000)
commit9d620d018c64affba26debf4397cb86c6767714e
treee7070f68ca2a98d0dcbb9e285c23287752b7951a
parent61acf067ac7820d5e5a02c17d3d55f7f19a8e52e
Simplify and fix error handling for most cases.

Many functions used a local variable called return_error, which was
initialized to zero.  If an error occurred, it was set to true.  Most
of the code paths checked were only executed if return_error was
false.  goto is clearer.

The code also seemed to be written under the curious assumption that
calling Py_DECREF() on a local variable would assign the variable to
NULL.  As a result, more of the error-exit code paths returned an
object that had a reference count of zero instead of just returning
NULL.  Fixed the code to explicitly assign NULL after the DECREF.

A bit more reformatting, but not much.

XXX Need a much better test suite for zlib, since it the current tests
don't exercise any of this broken code.
Modules/zlibmodule.c