summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_builtin.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-08-24 03:26:23 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-08-24 03:26:23 (GMT)
commit17689991e6ef5831eae57b2e91f178256d6d3ccb (patch)
tree21a954c86d8f461ecc06d8c6de8880429c6e97ec /Lib/test/test_builtin.py
parent9cf5ef4cc0015848ef831db31b19c77e6a4273e0 (diff)
downloadcpython-17689991e6ef5831eae57b2e91f178256d6d3ccb.zip
cpython-17689991e6ef5831eae57b2e91f178256d6d3ccb.tar.gz
cpython-17689991e6ef5831eae57b2e91f178256d6d3ccb.tar.bz2
only catch AttributeError in hasattr() #9666
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r--Lib/test/test_builtin.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index aef5de8..4e09ca5 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -495,15 +495,16 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, hasattr)
self.assertEqual(False, hasattr(sys, chr(sys.maxunicode)))
- # Check that hasattr allows SystemExit and KeyboardInterrupts by
+ # Check that hasattr propagates all exceptions outside of
+ # AttributeError.
class A:
def __getattr__(self, what):
- raise KeyboardInterrupt
- self.assertRaises(KeyboardInterrupt, hasattr, A(), "b")
+ raise SystemExit
+ self.assertRaises(SystemExit, hasattr, A(), "b")
class B:
def __getattr__(self, what):
- raise SystemExit
- self.assertRaises(SystemExit, hasattr, B(), "b")
+ raise ValueError
+ self.assertRaises(ValueError, hasattr, B(), "b")
def test_hash(self):
hash(None)