[Python-checkins] python/dist/src/Lib/test test_descr.py, 1.197, 1.198

mwh at users.sourceforge.net mwh at users.sourceforge.net
Fri Aug 15 07:07:49 EDT 2003


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv10737/Lib/test

Modified Files:
	test_descr.py 
Log Message:
Fix for

[ 784825 ] fix obscure crash in descriptor handling

Should be applied to release23-maint and in all likelyhood 
release22-maint, too.

Certainly doesn't apply to release21-maint.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.197
retrieving revision 1.198
diff -C2 -d -r1.197 -r1.198
*** test_descr.py	7 Aug 2003 14:58:10 -0000	1.197
--- test_descr.py	15 Aug 2003 13:07:47 -0000	1.198
***************
*** 3939,3942 ****
--- 3939,3972 ----
          pass
  
+ def vicious_descriptor_nonsense():
+     # A potential segfault spotted by Thomas Wouters in mail to
+     # python-dev 2003-04-17, turned into an example & fixed by Michael
+     # Hudson just less than four months later...
+     if verbose:
+         print "Testing vicious_descriptor_nonsense..."
+ 
+     class Evil(object):
+         def __hash__(self):
+             return hash('attr')
+         def __eq__(self, other):
+             del C.attr
+             return 0
+ 
+     class Descr(object):
+         def __get__(self, ob, type=None):
+             return 1
+ 
+     class C(object):
+         attr = Descr()
+ 
+     c = C()
+     c.__dict__[Evil()] = 0
+ 
+     vereq(c.attr, 1)
+     # this makes a crash more likely:
+     import gc; gc.collect()
+     vereq(hasattr(c, 'attr'), False)
+     
+ 
  def test_main():
      weakref_segfault() # Must be first, somehow
***************
*** 4030,4033 ****
--- 4060,4064 ----
      carloverre()
      filefault()
+     vicious_descriptor_nonsense()
  
      if verbose: print "All OK"





More information about the Python-checkins mailing list