]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport:
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 2 Feb 2003 19:38:19 +0000 (19:38 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 2 Feb 2003 19:38:19 +0000 (19:38 +0000)
revision 1.10
date: 2002/10/29 19:08:29;  author: gvanrossum;  state: Exp;  lines: +27 -0
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.

Lib/test/test_class.py

index 5240b3adfc51ca2c88efd8a8ab362e0d5da1acce..caa4234b63396764d20198e461955a168e76a258 100644 (file)
@@ -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"