[Python-checkins] python/dist/src/Lib/test test_class.py,1.7.6.1,1.7.6.2

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
2003年2月02日 11:38:22 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv29958/Lib/test
Modified Files:
 Tag: release22-maint
	test_class.py 
Log Message:
backport:
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.
Index: test_class.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_class.py,v
retrieving revision 1.7.6.1
retrieving revision 1.7.6.2
diff -C2 -d -r1.7.6.1 -r1.7.6.2
*** test_class.py	13 Jun 2002 21:36:35 -0000	1.7.6.1
--- test_class.py	2 Feb 2003 19:38:19 -0000	1.7.6.2
***************
*** 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"

AltStyle によって変換されたページ (->オリジナル) /