#2196 hasattr now allows SystemExit and KeyboardInterrupt to propagate

This commit is contained in:
Benjamin Peterson 2008-05-12 00:41:23 +00:00
parent 42bfa90f02
commit b9030f4f0d
3 changed files with 20 additions and 3 deletions

View file

@ -590,6 +590,16 @@ def test_hasattr(self):
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))