diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-11-09 16:17:24 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-11-09 16:17:24 (GMT) |
commit | 41c8321252a84d8a9d0ded374e7db7a4393036be (patch) | |
tree | d2e2f9c274be1c8b1e84b23863c9bda799356cb6 /Lib/test/test_file.py | |
parent | 20747fa167dc8224c01ab0ab2ece81c9c5927dec (diff) | |
download | cpython-41c8321252a84d8a9d0ded374e7db7a4393036be.zip cpython-41c8321252a84d8a9d0ded374e7db7a4393036be.tar.gz cpython-41c8321252a84d8a9d0ded374e7db7a4393036be.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_file.py')
-rw-r--r-- | Lib/test/test_file.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index a85e07c..cb1bdce 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -46,4 +46,15 @@ else: print "writelines accepted sequence of non-string objects" 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) |