diff options
author | R. David Murray <rdmurray@bitdance.com> | 2010-11-20 16:33:30 (GMT) |
---|---|---|
committer | R. David Murray <rdmurray@bitdance.com> | 2010-11-20 16:33:30 (GMT) |
commit | 6bb9989ae38cd2610e661d6e8899ef58dd9562e3 (patch) | |
tree | 3f91b1c8de11bbd1a218d39caf36c0997f5b9cf5 /Lib/test/test_isinstance.py | |
parent | f149e45a4e3311c2eb6ce63aa0b00b6dcacf01f5 (diff) | |
download | cpython-6bb9989ae38cd2610e661d6e8899ef58dd9562e3.zip cpython-6bb9989ae38cd2610e661d6e8899ef58dd9562e3.tar.gz cpython-6bb9989ae38cd2610e661d6e8899ef58dd9562e3.tar.bz2 |
#1574217: only swallow AttributeErrors in isinstance, not everything.
Patch and tests by Brian Harring, with improvements by Ralf Schmitt.
Diffstat (limited to 'Lib/test/test_isinstance.py')
-rw-r--r-- | Lib/test/test_isinstance.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index 9482e75..50920c5 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -81,6 +81,20 @@ class TestIsInstanceExceptions(unittest.TestCase): self.assertRaises(TypeError, isinstance, I(), C()) + # check that we don't mask non AttributeErrors + # see: http://bugs.python.org/issue1574217 + def test_isinstance_dont_mask_non_attribute_error(self): + class C(object): + def getclass(self): + raise RuntimeError() + __class__=property(getclass) + + c=C() + self.assertRaises(RuntimeError, isinstance, c, bool) + + # test another code path + class D: pass + self.assertRaises(RuntimeError, isinstance, c, D) # These tests are similar to above, but tickle certain code paths in |