[Jython-checkins] jython: Ignore IOException if attempting to truncate file for write
jim.baker
jython-checkins at python.org
Tue Feb 3 06:34:03 CET 2015
https://hg.python.org/jython/rev/31b98240dcf1
changeset: 7567:31b98240dcf1
user: Jim Baker <jim.baker at rackspace.com>
date: Mon Feb 02 22:33:45 2015 -0700
summary:
Ignore IOException if attempting to truncate file for write
Opening files for write will call FileChannel#truncate(0). For special
files like /dev/null, such calls raise IOException, which is not
specific. Attempting to distinguish with the exception message causes
internationalization issues (http://bugs.jython.org/issue1944), so
simply suppress. This should just work, since other more detailed
exceptions are raised for cases like attempting to write to say
/dev/cannot-write-here
files:
src/org/python/core/io/FileIO.java | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/org/python/core/io/FileIO.java b/src/org/python/core/io/FileIO.java
--- a/src/org/python/core/io/FileIO.java
+++ b/src/org/python/core/io/FileIO.java
@@ -216,12 +216,10 @@
// ERROR_INVALID_HANDLE on ttys. Identifying those by the IOException
// message is tedious as their messages are localized, so we suppress them
// all =[
- if (Platform.IS_WINDOWS ||
- ((Platform.IS_SOLARIS || Platform.IS_LINUX)
- && Errno.EINVAL.description().equals(ioe.getMessage()))) {
- return;
- }
- throw Py.IOError(ioe);
+ //
+ // Unfortunately attempting to distinguish by localized messages is too hard.
+ // Give up and swallow the exception.
+ // See http://bugs.jython.org/issue1944
}
}
}
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list