[Jython-checkins] jython (merge default -> default): Merge to trunk
jeff.allen
jython-checkins at python.org
Tue Nov 10 14:07:25 EST 2015
https://hg.python.org/jython/rev/f7db3ab5ca7b
changeset: 7799:f7db3ab5ca7b
parent: 7794:fa0239372f0e
parent: 7798:0381d60ca611
user: Jeff Allen <ja.py at farowl.co.uk>
date: Tue Nov 10 19:06:30 2015 +0000
summary:
Merge to trunk
files:
Lib/test/regrtest.py | 17 +-
Lib/test/test_classpathimporter.py | 1 +
Lib/test/test_support.py | 1 +
Lib/test/test_tempfile.py | 5 +-
build.xml | 8 +-
extlibs/jnr-constants-0.8.8.jar | Bin
extlibs/jnr-constants-0.9.0.jar | Bin
extlibs/jnr-posix-3.0.17.jar | Bin
extlibs/jnr-posix-3.0.20.jar | Bin
src/org/python/modules/posix/PosixModule.java | 68 ++++++++-
10 files changed, 79 insertions(+), 21 deletions(-)
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1367,20 +1367,19 @@
'java.posix': # Expected to fail on Linux
"""
- test_classpathimporter # Fails in test_loader_get_code
test_codecencodings_tw # Fails in test_multibytecodec_support.py
test_jython_launcher # /usr/bin/env: python2.7 -E: No such file or directory
# These leak file handles on a grand scale (observed on Ubuntu 14.04),
# causing failures elsewhere, but they don't actually fail.
- test_docxmlrpc # 206 leaked handles issue 2320
- test_httpservers # 721 leaked handles issue 2320
- ## test_imaplib # 92 leaked handles issue 2320 (tolerable)
- test_socketserver # 1344 leaked handles issue 2320
- test_telnetlib # 1588 leaked handles issue 2320
- ## test_timeout # 123 leaked handles issue 2320 (tolerable)
- test_urllib2_localnet # 763 leaked handles issue 2320
- test_xmlrpc # 453 leaked handles issue 2320
+ test_docxmlrpc # 206 leaked handles issue 2420
+ test_httpservers # 721 leaked handles issue 2420
+ ## test_imaplib # 92 leaked handles issue 2420 (tolerable)
+ test_socketserver # 1344 leaked handles issue 2420
+ test_telnetlib # 1588 leaked handles issue 2420
+ ## test_timeout # 123 leaked handles issue 2420 (tolerable)
+ test_urllib2_localnet # 763 leaked handles issue 2420
+ test_xmlrpc # 453 leaked handles issue 2420
"""
}
diff --git a/Lib/test/test_classpathimporter.py b/Lib/test/test_classpathimporter.py
--- a/Lib/test/test_classpathimporter.py
+++ b/Lib/test/test_classpathimporter.py
@@ -118,6 +118,7 @@
self.assertTrue(loader.is_package('jar_pkg'))
self.assertFalse(loader.is_package('jar_pkg.prefer_compiled'))
+ @unittest.skipIf(test_support.is_jython_posix, "FIXME: failing on Linux issue #2422")
def test_loader_get_code(self):
# Execute Python code out of the JAR
jar = self.prepareJar('classimport.jar')
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -52,6 +52,7 @@
# We use these extensively in adapting the regression tests for Jython
is_jython = sys.platform.startswith('java')
is_jython_nt = is_jython and (os._name == 'nt')
+is_jython_posix = is_jython and (os._name == 'posix')
class Error(Exception):
"""Base class for regression test exceptions."""
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -848,7 +848,10 @@
# A SpooledTemporaryFile should roll over to a real file on fileno()
f = self.do_create(max_size=30)
self.assertFalse(f._rolled)
- self.assertTrue(f.fileno() > 0)
+ if support.is_jython:
+ self.assertIsNotNone(f.fileno())
+ else:
+ self.assertGreater(f.fileno(), 0)
self.assertTrue(f._rolled)
def test_multiple_close_before_rollover(self):
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -174,8 +174,8 @@
<pathelement path="${extlibs.dir}/jffi-1.2.7.jar"/>
<pathelement path="${extlibs.dir}/jnr-ffi-2.0.4.jar"/>
<pathelement path="${extlibs.dir}/jnr-netdb-1.1.4.jar"/>
- <pathelement path="${extlibs.dir}/jnr-posix-3.0.17.jar"/>
- <pathelement path="${extlibs.dir}/jnr-constants-0.8.8.jar"/>
+ <pathelement path="${extlibs.dir}/jnr-posix-3.0.20.jar"/>
+ <pathelement path="${extlibs.dir}/jnr-constants-0.9.0.jar"/>
<pathelement path="${extlibs.dir}/jline-2.12.1.jar"/>
<pathelement path="${extlibs.dir}/netty-buffer-4.0.31.Final.jar"/>
<pathelement path="${extlibs.dir}/netty-codec-4.0.31.Final.jar"/>
@@ -618,8 +618,8 @@
<zipfileset src="extlibs/jffi-1.2.7.jar"/>
<zipfileset src="${extlibs.dir}/jnr-ffi-2.0.4.jar"/>
<zipfileset src="${extlibs.dir}/jnr-netdb-1.1.4.jar"/>
- <zipfileset src="${extlibs.dir}/jnr-posix-3.0.17.jar"/>
- <zipfileset src="${extlibs.dir}/jnr-constants-0.8.8.jar"/>
+ <zipfileset src="${extlibs.dir}/jnr-posix-3.0.20.jar"/>
+ <zipfileset src="${extlibs.dir}/jnr-constants-0.9.0.jar"/>
<zipfileset src="extlibs/xml-apis-2.11.0.jar" excludes="META-INF/services/*"/>
<zipfileset src="extlibs/xercesImpl-2.11.0.jar" excludes="META-INF/services/*"/>
<rule pattern="org.apache.xml.**" result="org.python.apache.xml. at 1"/>
diff --git a/extlibs/jnr-constants-0.8.8.jar b/extlibs/jnr-constants-0.8.8.jar
deleted file mode 100644
index eee5ab879c62b3a5354ca8d2e9b9564b55122be0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
[stripped]
diff --git a/extlibs/jnr-constants-0.9.0.jar b/extlibs/jnr-constants-0.9.0.jar
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..52040d3c89fb843129c7e566a1e8dab0a7f05d81
GIT binary patch
[stripped]
diff --git a/extlibs/jnr-posix-3.0.17.jar b/extlibs/jnr-posix-3.0.17.jar
deleted file mode 100644
index 47694b9c819436d6f39633d13d1dc6c071ce4a33..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
[stripped]
diff --git a/extlibs/jnr-posix-3.0.20.jar b/extlibs/jnr-posix-3.0.20.jar
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f0c5961c380097cb98754976e37f33da0c50303f
GIT binary patch
[stripped]
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
@@ -15,8 +15,8 @@
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.LinkOption;
+import java.nio.file.NoSuchFileException;
import java.nio.file.NotLinkException;
-import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributeView;
@@ -34,9 +34,11 @@
import jnr.posix.FileStat;
import jnr.posix.POSIX;
import jnr.posix.POSIXFactory;
+import jnr.posix.POSIXHandler;
import jnr.posix.Times;
+import jnr.posix.WindowsRawFileStat;
import jnr.posix.util.FieldAccess;
-import jnr.posix.util.Platform;
+import jnr.posix.windows.CommonFileInformation;
import org.python.core.BufferProtocol;
import org.python.core.ClassDictInit;
@@ -53,8 +55,8 @@
import org.python.core.PyString;
import org.python.core.PySystemState;
import org.python.core.PyTuple;
+import org.python.core.Untraversable;
import org.python.core.imp;
-import org.python.core.Untraversable;
import org.python.core.io.FileIO;
import org.python.core.io.IOBase;
import org.python.core.io.RawIOBase;
@@ -75,7 +77,8 @@
private static final OS os = OS.getOS();
/** Platform specific POSIX services. */
- private static final POSIX posix = POSIXFactory.getPOSIX(new PythonPOSIXHandler(), true);
+ private static final POSIXHandler posixHandler = new PythonPOSIXHandler();
+ private static final POSIX posix = POSIXFactory.getPOSIX(posixHandler, true);
/** os.open flags. */
private static final int O_RDONLY = 0x0;
@@ -222,6 +225,8 @@
if (fdObj.isInteger()) {
int intFd = fdObj.asInt();
switch (intFd) {
+ case -1:
+ break;
case 0:
return new FDUnion(FileDescriptor.in);
case 1:
@@ -352,6 +357,7 @@
}
}
+ @Hide(OS.NT)
public static void closerange(PyObject fd_lowObj, PyObject fd_highObj) {
int fd_low = getFD(fd_lowObj).getIntFD(false);
int fd_high = getFD(fd_highObj).getIntFD(false);
@@ -1363,10 +1369,18 @@
try {
FDUnion fd = getFD(fdObj);
FileStat stat;
- if (fd.isIntFD()) {
- stat = posix.fstat(fd.intFD);
+ if (os != OS.NT) {
+ if (fd.isIntFD()) {
+ stat = posix.fstat(fd.intFD);
+ } else {
+ stat = posix.fstat(fd.javaFD);
+ }
} else {
- stat = posix.fstat(fd.javaFD);
+ // FIXME: jnr-posix fstat work-around. See issue #2320.
+ stat = new WindowsRawFileStat2(posix, posixHandler);
+ if (posix.fstat(fd.javaFD, stat) < 0) {
+ throw Py.OSError(Errno.EBADF);
+ }
}
return PyStatResult.fromFileStat(stat);
} catch (PyException ex) {
@@ -1374,4 +1388,44 @@
}
}
}
+
+ /*
+ * Extend the Windows stat object defined by jnr.posix, which in jnr-posix 2.0.4 is buggy to the
+ * extent that st_mode is always zero. Remarkably, it is possible to fix this by defining a
+ * cunning replacement.
+ */
+ private static class WindowsRawFileStat2 extends WindowsRawFileStat {
+
+ public WindowsRawFileStat2(POSIX posix, POSIXHandler handler) {
+ super(posix, handler);
+ }
+
+ private int mode; // Replaces st_mode
+
+ @Override
+ public void setup(CommonFileInformation fileInfo) {
+ super.setup(fileInfo);
+ // CommonFileInformation gives us (DOS-style) file attributes, not access rights.
+ int attr = fileInfo.getFileAttributes();
+ int mode = ALL_READ;
+ if ((attr & CommonFileInformation.FILE_ATTRIBUTE_READONLY) == 0) {
+ // Writable: assume by all
+ mode |= ALL_WRITE;
+ }
+ if ((attr & CommonFileInformation.FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ // Directory: assume by all can look things up in it.
+ mode |= S_IFDIR | S_IXUGO;
+ } else {
+ // Regular file
+ mode |= S_IFREG;
+ }
+ this.mode = mode;
+ }
+
+ @Override
+ public int mode() {
+ return mode;
+ }
+ }
+
}
--
Repository URL: https://hg.python.org/jython
More information about the Jython-checkins
mailing list