[Jython-checkins] jython (2.5): fix os.utimes/symlink failing to raise OSErrors
philip.jenvey
jython-checkins at python.org
Sun Jun 5 03:04:07 CEST 2011
http://hg.python.org/jython/rev/d75393f1eb8d
changeset: 6233:d75393f1eb8d
branch: 2.5
parent: 6208:69dfd5ee9d84
user: Philip Jenvey <pjenvey at underboss.org>
date: Sat Jun 04 18:00:50 2011 -0700
summary:
fix os.utimes/symlink failing to raise OSErrors
fixes #1755
files:
Lib/test/test_os_jy.py | 7 ++++++-
NEWS | 1 +
src/org/python/modules/posix/PosixModule.java | 8 ++++++--
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_os_jy.py b/Lib/test/test_os_jy.py
--- a/Lib/test/test_os_jy.py
+++ b/Lib/test/test_os_jy.py
@@ -12,11 +12,16 @@
open(test_support.TESTFN, 'w').close()
def tearDown(self):
- os.remove(test_support.TESTFN)
+ if os.path.exists(test_support.TESTFN):
+ os.remove(test_support.TESTFN)
def test_issue1727(self):
os.stat(*(test_support.TESTFN,))
+ def test_issue1755(self):
+ os.remove(test_support.TESTFN)
+ self.assertRaises(OSError, os.utime, test_support.TESTFN, None)
+
def test_main():
test_support.run_unittest(OSTestCase)
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@
Bugs Fixed
- [ 1727 ] Error in Jython 2.5.2 with os.stat and varargs
- [ 1735 ] return type of os.read is unicode, not str
+ - [ 1755 ] os.utime('/tmp/nonexistent-file', None) fails to raise OSError
Jython 2.5.2
same as 2.5.2rc4
diff --git a/src/org/python/modules/posix/PosixModule.java b/src/org/python/modules/posix/PosixModule.java
--- a/src/org/python/modules/posix/PosixModule.java
+++ b/src/org/python/modules/posix/PosixModule.java
@@ -705,7 +705,9 @@
@Hide(OS.NT)
public static void symlink(String src, String dst) {
ensurePath(src);
- posix.symlink(src, absolutePath(dst));
+ if (posix.symlink(src, absolutePath(dst)) < 0) {
+ throw errorFromErrno();
+ }
}
public static PyString __doc__system = new PyString(
@@ -762,7 +764,9 @@
} else {
throw Py.TypeError("utime() arg 2 must be a tuple (atime, mtime)");
}
- posix.utimes(absolutePath(path), atimeval, mtimeval);
+ if (posix.utimes(absolutePath(path), atimeval, mtimeval) < 0) {
+ throw errorFromErrno(path);
+ }
}
/**
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list