]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
abstract_get_bases(): Clarify exactly what the return values and
authorBarry Warsaw <barry@python.org>
Tue, 23 Apr 2002 22:45:44 +0000 (22:45 +0000)
committerBarry Warsaw <barry@python.org>
Tue, 23 Apr 2002 22:45:44 +0000 (22:45 +0000)
commitf16951cffe9e4171769213bbe1aecec3d8f5200a
tree65880c11281cc4b26c89a05c0ad134da17280d30
parent3adf8d1daef8d323c405fd157e40cbae1d636c23
abstract_get_bases(): Clarify exactly what the return values and
states can be for this function, and ensure that only AttributeErrors
are masked.  Any other exception raised via the equivalent of
getattr(cls, '__bases__') should be propagated up.

abstract_issubclass(): If abstract_get_bases() returns NULL, we must
call PyErr_Occurred() to see if an exception is being propagated, and
return -1 or 0 as appropriate.  This is the specific fix for a problem
whereby if getattr(derived, '__bases__') raised an exception, an
"undetected error" would occur (under a debug build).  This nasty
situation was uncovered when writing a security proxy extension type
for the Zope3 project, where the security proxy raised a Forbidden
exception on getattr of __bases__.

PyObject_IsInstance(), PyObject_IsSubclass(): After both calls to
abstract_get_bases(), where we're setting the TypeError if the return
value is NULL, we must first check to see if an exception occurred,
and /not/ mask an existing exception.

Neil Schemenauer should double check that these changes don't break
his ExtensionClass examples (there aren't any test cases for those
examples and abstract_get_bases() was added by him in response to
problems with ExtensionClass).  Neil, please add test cases if
possible!

I belive this is a bug fix candidate for Python 2.2.2.
Objects/abstract.c