Index: PyFile.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/PyFile.java,v retrieving revision 2.29 diff -u -r2.29 PyFile.java --- PyFile.java 6 Aug 2003 11:46:26 -0000 2.29 +++ PyFile.java 27 Feb 2004 21:06:31 -0000 @@ -733,14 +733,24 @@ c3 = mode.charAt(2); } } + String jmode = "r"; if (c1 == 'r') { - if (c2 == '+' || c3 == '+') jmode = "rw"; - else jmode = "r"; + if (c2 == '+' || c3 == '+') + jmode = "rw"; + else + jmode = "r"; } - else if (c1 == 'w' || c1 == 'a') jmode = "rw"; + else if (c1 == 'w' || c1 == 'a') + jmode = "rw"; + try { - java.io.File f = new java.io.File(name); + java.io.File f = new java.io.File(name); + if (c1 == 'r') { + if (!f.exists()) { + throw new java.io.IOException("No such file or directory: " + name); + } + } if (c1 == 'w') { // Hack to truncate the file without deleting it: // create a FileOutputStream for it and close it again.