From: Charles D. <cd...@sp...> - 2002-10-25 02:08:24
|
G'day. I've encountered a situation where issubclass() reports that an item's class is a subclass of a given parent class, yet isinstance() reports that the item is not an instance of that parent class. To demonstrate: ---- Correct behaviour >>> class A: pass ... >>> class B(A): pass ... >>> isinstance(B(), A) 1 >>> issubclass(B,A) 1 ---- Observed Incorrect behaviour >>> print item.__class__ com.wutka.dtd.DTDSequence >>> isinstance(item, DTDItem) 0 >>> issubclass(DTDSequence, DTDItem) 1 >>> issubclass(item.__class__, DTDItem) 1 I'm using Jython 2.1 (from version 2.1.0-8 of the debian jython package) on a Sun JRE (1.4.1_01) with no JIT enabled. The DTD parsing library which this is occuring with is available at http://www.wutka.com/dtdparser.html; the javadocs are available from http://www.wutka.com/dtdparserapi/index.html. Any insight you might be able to provide into why this could be occuring would be greatly appreciated. Thanks! |