[Python-checkins] CVS: python/dist/src/Lib/test test_file.py,1.3,1.4

Jeremy Hylton jhylton@users.sourceforge.net
Fri, 09 Nov 2001 08:17:11 -0800


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

Modified Files:
	test_file.py 
Log Message:
Fix SF buf #476953: Bad more for opening file gives bad msg.

If fopen() fails with EINVAL it means that the mode argument is
invalid.  Return the mode in the error message instead of the
filename.


Index: test_file.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_file.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_file.py	2001/01/17 19:11:13	1.3
--- test_file.py	2001/11/09 16:17:09	1.4
***************
*** 47,49 ****
--- 47,60 ----
  f.close()
  
+ # verify that we get a sensible error message for bad made argument
+ bad_mode = "qwerty"
+ try:
+     open(TESTFN, bad_mode)
+ except IOError, msg:
+     s = str(msg)
+     if s.find(TESTFN) != -1 or s.find(bad_mode) == -1:
+         print "bad error message for invalid mode: %s" % s
+ else:
+     print "no error for invalid mode: %s" % bad_mode
+ 
  os.unlink(TESTFN)