summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-05-12 00:41:23 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-05-12 00:41:23 (GMT)
commitb9030f4f0d566c8ae2eeb28ed858f02f3b853ae7 (patch)
tree526da2f8d50d0abaebcd5177f203adae5df7ee43 /Lib
parent42bfa90f02f0055ea163df9103ebed873ee1dbb0 (diff)
downloadcpython-b9030f4f0d566c8ae2eeb28ed858f02f3b853ae7.zip
cpython-b9030f4f0d566c8ae2eeb28ed858f02f3b853ae7.tar.gz
cpython-b9030f4f0d566c8ae2eeb28ed858f02f3b853ae7.tar.bz2
#2196 hasattr now allows SystemExit and KeyboardInterrupt to propagate
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_builtin.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index 1e559eb..15d80a3 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -590,6 +590,16 @@ class BuiltinTest(unittest.TestCase):
if have_unicode:
self.assertRaises(UnicodeError, hasattr, sys, unichr(sys.maxunicode))
+ # Check that hasattr allows SystemExit and KeyboardInterrupts by
+ class A:
+ def __getattr__(self, what):
+ raise KeyboardInterrupt
+ self.assertRaises(KeyboardInterrupt, hasattr, A(), "b")
+ class B:
+ def __getattr__(self, what):
+ raise SystemExit
+ self.assertRaises(SystemExit, hasattr, B(), "b")
+
def test_hash(self):
hash(None)
self.assertEqual(hash(1), hash(1L))