[Python-checkins] python/dist/src/Lib/test test_descr.py,1.195,1.196

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Sun, 29 Jun 2003 08:44:09 -0700


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

Modified Files:
	test_descr.py 
Log Message:
SF bug #762455: Python segfaults when sys.stdout is changed in getattr

* Added unittest that fails before, but not after Neil's fix to ceval.c.



Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.195
retrieving revision 1.196
diff -C2 -d -r1.195 -r1.196
*** test_descr.py	18 Jun 2003 01:13:41 -0000	1.195
--- test_descr.py	29 Jun 2003 15:44:07 -0000	1.196
***************
*** 3917,3920 ****
--- 3917,3934 ----
      del o
  
+ # Fix SF #762455, segfault when sys.stdout is changed in getattr
+ def filefault():
+     if verbose:
+         print "Testing sys.stdout is changed in getattr..."
+     import sys
+     class StdoutGuard:
+         def __getattr__(self, attr):
+             sys.stdout = sys.__stdout__
+             raise RuntimeError("Premature access to sys.stdout.%s" % attr)
+     sys.stdout = StdoutGuard()
+     try:
+         print "Oops!"
+     except RuntimeError:
+         pass
  
  def test_main():
***************
*** 4008,4011 ****
--- 4022,4026 ----
      proxysuper()
      carloverre()
+     filefault()
  
      if verbose: print "All OK"