[Python-checkins] python/dist/src/Lib/test test_descr.py,1.142,1.143

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
2002年6月20日 15:23:17 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv4718/Lib/test
Modified Files:
	test_descr.py 
Log Message:
SF 569257 -- Name mangle double underscored variable names in __slots__.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.142
retrieving revision 1.143
diff -C2 -d -r1.142 -r1.143
*** test_descr.py	18 Jun 2002 16:49:45 -0000	1.142
--- test_descr.py	20 Jun 2002 22:23:15 -0000	1.143
***************
*** 1061,1064 ****
--- 1061,1082 ----
 vereq(x.c, 3)
 
+ class C4(object):
+ """Validate name mangling"""
+ __slots__ = ['__a']
+ def __init__(self, value):
+ self.__a = value
+ def get(self):
+ return self.__a
+ x = C4(5)
+ verify(not hasattr(x, '__dict__'))
+ verify(not hasattr(x, '__a'))
+ vereq(x.get(), 5)
+ try:
+ x.__a = 6
+ except AttributeError:
+ pass
+ else:
+ raise TestFailed, "Double underscored names not mangled"
+ 
 # Make sure slot names are proper identifiers
 try:

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