[Image-SIG] PIL patch

Fred L. Drake Fred L. Drake, Jr." <fdrake@acm.org
Wed, 27 May 1998 09:23:16 -0400 (EDT)

Richard Jones writes:
 > +           /* IndexError is OK */
 > +           if (PyErr_Occurred() == PyExc_IndexError) {
 > +               PyErr_Clear();

  This is an inappropriate use of PyErr_Occurred() in recent versions
of Python (starting from when the standard exceptions became
classes).  The right way to make this test is:

	/* IndexError is OK */
	if ((PyErr_Occurred() != NULL)
	    && PyErr_ExceptionMatches(PyExc_IndexError)) {

  This allows the sequence implementation to raise a subclass of
IndexError and this will still work.  Note that PyErr_Occurred() must
be true before calling PyErr_ExceptionMatches().


Fred L. Drake, Jr.
Corporation for National Research Initiatives
1895 Preston White Drive    Reston, VA  20191