[Python-checkins] python/dist/src/Lib/test test_descr.py,1.113.4.14,1.113.4.15
gvanrossum@sourceforge.net
gvanrossum@sourceforge.net
Mon, 13 May 2002 11:30:42 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv10109/Lib/test
Modified Files:
Tag: release22-maint
test_descr.py
Log Message:
Backport from 2.3:
Jim Fulton reported a segfault in dir(). A heavily proxied object
returned a proxy for __class__ whose __bases__ was also a proxy. The
merge_class_dict() helper for dir() assumed incorrectly that __bases__
would always be a tuple and used the in-line tuple API on the proxy.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.113.4.14
retrieving revision 1.113.4.15
diff -C2 -d -r1.113.4.14 -r1.113.4.15
*** test_descr.py 23 Apr 2002 04:02:54 -0000 1.113.4.14
--- test_descr.py 13 May 2002 18:30:40 -0000 1.113.4.15
***************
*** 366,369 ****
--- 366,389 ----
vereq(dir(None), dir(Ellipsis))
+ # Nasty test case for proxied objects
+ class Wrapper(object):
+ def __init__(self, obj):
+ self.__obj = obj
+ def __repr__(self):
+ return "Wrapper(%s)" % repr(self.__obj)
+ def __getitem__(self, key):
+ return Wrapper(self.__obj[key])
+ def __len__(self):
+ return len(self.__obj)
+ def __getattr__(self, name):
+ return Wrapper(getattr(self.__obj, name))
+
+ class C(object):
+ def __getclass(self):
+ return Wrapper(type(self))
+ __class__ = property(__getclass)
+
+ dir(C()) # This used to segfault
+
binops = {
'add': '+',