Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(182342)

Unified Diff: Lib/test/test_isinstance.py

Issue 1574217: isinstance swallows exceptions
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Objects/abstract.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Lib/test/test_isinstance.py
===================================================================
--- Lib/test/test_isinstance.py (revision 82887)
+++ Lib/test/test_isinstance.py (working copy)
@@ -81,7 +81,21 @@
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
# issubclass() instead of isinstance() -- really PyObject_IsSubclass()
« no previous file with comments | « no previous file | Objects/abstract.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+