[Jython-checkins] jython: Fix minor but build-breaking errors on Windows from 7616:9b911ee72842
jim.baker
jython-checkins at python.org
Mon Mar 16 17:00:52 CET 2015
https://hg.python.org/jython/rev/19eee6ac6d0a
changeset: 7617:19eee6ac6d0a
user: Jim Baker <jim.baker at rackspace.com>
date: Mon Mar 16 10:00:47 2015 -0600
summary:
Fix minor but build-breaking errors on Windows from 7616:9b911ee72842
Better exception handling and correct parsing of S_IWUSR in chmod.
Completes fix for http://bugs.jython.org/issue2120
files:
src/org/python/modules/posix/PosixModule.java | 16 +++++++--
1 files changed, 12 insertions(+), 4 deletions(-)
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
@@ -12,6 +12,7 @@
import java.nio.channels.Channel;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.FileChannel;
+import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.LinkOption;
@@ -293,7 +294,7 @@
public static void chmod(PyObject path, int mode) {
if (os == OS.NT) {
try {
- if (!absolutePath(path).toFile().setWritable((mode & FileStat.S_IWUSR) == 0)) {
+ if (!absolutePath(path).toFile().setWritable((mode & FileStat.S_IWUSR) != 0)) {
throw Py.OSError(Errno.EPERM, path);
}
} catch (SecurityException ex) {
@@ -658,9 +659,16 @@
public static void mkdir(PyObject path, int mode) {
if (os == OS.NT) {
try {
- if (!absolutePath(path).toFile().mkdir()) {
- throw Py.OSError(Errno.EPERM, path);
- }
+ Path nioPath = absolutePath(path);
+ // Windows does not use any mode attributes in creating a directory;
+ // see the corresponding function in posixmodule.c, posix_mkdir;
+ // further work on mapping mode to PosixAttributes would have to be done
+ // for non Windows; posix.mkdir would still be necessary for mode bits like stat.S_ISGID
+ Files.createDirectory(nioPath);
+ } catch (FileAlreadyExistsException ex) {
+ throw Py.OSError(Errno.EEXIST, path);
+ } catch (IOException ioe) {
+ throw Py.OSError(ioe);
} catch (SecurityException ex) {
throw Py.OSError(Errno.EACCES, path);
}
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list