[New-bugs-announce] [issue7555] Wrong return value of isinstance() function

Leo Spidian report at bugs.python.org
Mon Dec 21 11:25:58 CET 2009


New submission from Leo Spidian <zhangdongying1986 at gmail.com>:

isinstance() function returns False while surpposed to return True
============ tt.py =================
import ss
class tt:
    def __init__(self, s):
        if not isinstance(s, ss.ss):
            raise Exception("s is not an instance of ss.ss")
====================================
============ ss.py =================
import tt
class sss:
    pass
class ss(sss):
    pass
if __name__ == '__main__':
    s = ss()
    print isinstance(s, ss)
    t = tt.tt(s)
====================================
Run ss.py:
True
Traceback (most recent call last):
  File "D:\workspace\PostDocs\ss.py", line 11, in <module>
    t = tt.tt(s)
  File "D:\workspace\PostDocs\tt.py", line 6, in __init__
    raise Exception("s is not an instance of ss.ss")
Exception: s is not an instance of ss.ss

----------
components: None
files: ss.py
messages: 96733
nosy: leospidian
severity: normal
status: open
title: Wrong return value of isinstance() function
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file15641/ss.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7555>
_______________________________________


More information about the New-bugs-announce mailing list