[Python-checkins] python/dist/src/Lib/test test_class.py,1.9,1.10
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Tue, 29 Oct 2002 11:08:32 -0800
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv23989
Modified Files:
test_class.py
Log Message:
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.
Index: test_class.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_class.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_class.py 30 Jul 2002 23:26:01 -0000 1.9
--- test_class.py 29 Oct 2002 19:08:29 -0000 1.10
***************
*** 289,290 ****
--- 289,317 ----
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"