From: <nr...@us...> - 2008-07-25 06:07:26
|
Revision: 4998 http://jython.svn.sourceforge.net/jython/?rev=4998&view=rev Author: nriley Date: 2008-07-25 06:07:24 +0000 (Fri, 25 Jul 2008) Log Message: ----------- Suppress exception truncating /dev/null when opening it for write on Linux and Solaris; should fix test_os. Modified Paths: -------------- branches/asm/src/org/python/core/io/FileIO.java Modified: branches/asm/src/org/python/core/io/FileIO.java =================================================================== --- branches/asm/src/org/python/core/io/FileIO.java 2008-07-24 23:42:09 UTC (rev 4997) +++ branches/asm/src/org/python/core/io/FileIO.java 2008-07-25 06:07:24 UTC (rev 4998) @@ -154,7 +154,18 @@ if (appending) { seek(0, 2); } else if (writable && !readable) { - truncate(0); + try { + fileChannel.truncate(0); + } catch (IOException ioe) { + // On Solaris and Linux, ftruncate(3C) returns EINVAL + // if not a regular file whereas, e.g., + // open("/dev/null", "w") works fine. Because we have + // to simulate the "w" mode in Java, we suppress the + // exception. + if (ioe.getMessage().equals("Invalid argument")) + return; + throw Py.IOError(ioe); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |