summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-10-29 19:08:29 (GMT)
committerGuido van Rossum <guido@python.org>2002-10-29 19:08:29 (GMT)
commit2c9590f62549ded76dbdf096ee106e7b43f004f5 (patch)
tree382ae7d63d0c446471898f354b2bb7fe9404880c /Lib
parentf740bdf3379046701d23c8849d51aadd8377dc17 (diff)
downloadcpython-2c9590f62549ded76dbdf096ee106e7b43f004f5.zip
cpython-2c9590f62549ded76dbdf096ee106e7b43f004f5.tar.gz
cpython-2c9590f62549ded76dbdf096ee106e7b43f004f5.tar.bz2
Added test for this fix to classobject.c:
Since properties are supported here, is possible that instance_getattr2() raises an exception. Fix all code that made this assumption. Backport candidate.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_class.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index e90a790..3c3ea06 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -288,3 +288,30 @@ except RuntimeError:
pass
else:
raise TestFailed, "how could this not have overflowed the stack?"
+
+
+# Tests for exceptions raised in instance_getattr2().
+
+def booh(self):
+ raise AttributeError, "booh"
+
+class A:
+ a = property(booh)
+try:
+ A().a # Raised AttributeError: A instance has no attribute 'a'
+except AttributeError, x:
+ if str(x) is not "booh":
+ print "attribute error for A().a got masked:", str(x)
+
+class E:
+ __eq__ = property(booh)
+E() == E() # In debug mode, caused a C-level assert() to fail
+
+class I:
+ __init__ = property(booh)
+try:
+ I() # In debug mode, printed XXX undetected error and raises AttributeError
+except AttributeError, x:
+ pass
+else:
+ print "attribute error for I.__init__ got masked"