From jython-checkins at python.org Sun Jun 5 03:04:07 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sun, 05 Jun 2011 03:04:07 +0200 Subject: [Jython-checkins] =?utf8?q?jython_=282=2E5=29=3A_fix_os=2Eutimes/?= =?utf8?q?symlink_failing_to_raise_OSErrors?= Message-ID: http://hg.python.org/jython/rev/d75393f1eb8d changeset: 6233:d75393f1eb8d branch: 2.5 parent: 6208:69dfd5ee9d84 user: Philip Jenvey 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 From jython-checkins at python.org Sun Jun 5 03:04:07 2011 From: jython-checkins at python.org (philip.jenvey) Date: Sun, 05 Jun 2011 03:04:07 +0200 Subject: [Jython-checkins] =?utf8?q?jython_=28merge_2=2E5_-=3E_default=29?= =?utf8?q?=3A_merge_with_2=2E5=3A_fix_os=2Eutimes/symlink_failing_to_raise?= =?utf8?q?_OSErrors?= Message-ID: http://hg.python.org/jython/rev/f9bc8cd4da8f changeset: 6234:f9bc8cd4da8f parent: 6232:b75d6d8f75ed parent: 6233:d75393f1eb8d user: Philip Jenvey date: Sat Jun 04 18:02:13 2011 -0700 summary: merge with 2.5: 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