I did some more debugging on the Jython source, and this bug is related to problems with jnr-posix-1.1.8.jar which is used by Jython 2.5.3. This java library provides POSIX functionality to the os module in Jython.

When Jython is installed directly from jython.org, then a working version of jnr-posix is linked in as part of the Jython jar, which is the reason why this version works.

I tried to compile in support for jnr-posix-2.5.0.jar in jython-2.5.4-rc1. This approach requires a source code patch (attached) for the newer jnr-posix-2.5.0 library. It also requires installation of jnr-constants-0.8.5.jar and jnr-ffi-1.0.0.jar.

The easiest workaround for now, is to download and install jython-2.5.4-rc1 from jython.org, and wait for a stable version of Jython 2.7, which includes the required upgrade of jnr-posix, since doing this patch properly requires quite extensive changes to Jython.

I have attached the patch I was working on, in case someone wants to take this approach further.

Best regards,
Nils Ulltveit-Moe
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 jython (2.5.4-RC1-1ubuntu1) trusty; urgency=medium
   * Fixes chmod problem in earlier versions, which prevents installation of setuptools on Jython
Author: Nils Ulltveit-Moe <n...@u-moe.no>

The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- jython-2.5.4-RC1.orig/src/org/python/core/PySystemState.java
+++ jython-2.5.4-RC1/src/org/python/core/PySystemState.java
@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentMa
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
-import org.jruby.ext.posix.util.Platform;
+import jnr.posix.util.Platform;
 import org.python.Version;
 import org.python.core.adapter.ClassicPyObjectAdapter;
 import org.python.core.adapter.ExtensiblePyObjectAdapter;
--- jython-2.5.4-RC1.orig/src/org/python/core/io/FileIO.java
+++ jython-2.5.4-RC1/src/org/python/core/io/FileIO.java
@@ -13,7 +13,7 @@ import java.nio.channels.Channels;
 import java.nio.channels.FileChannel;
 import com.kenai.constantine.platform.Errno;
-import org.jruby.ext.posix.util.Platform;
+import jnr.posix.util.Platform;
 import org.python.core.Py;
 import org.python.core.PyString;
 import org.python.core.util.RelativeFile;
--- jython-2.5.4-RC1.orig/src/org/python/core/util/PlatformUtil.java
+++ jython-2.5.4-RC1/src/org/python/core/util/PlatformUtil.java
@@ -1,7 +1,7 @@
 /* Copyright (c) 2009 Jython project */
 package org.python.core.util;
-import org.jruby.ext.posix.util.Platform;
+import jnr.posix.util.Platform;
  * Methods for testing the platform/operating system that we are on.
--- jython-2.5.4-RC1.orig/src/org/python/modules/errno.java
+++ jython-2.5.4-RC1/src/org/python/modules/errno.java
@@ -4,7 +4,7 @@ package org.python.modules;
 import com.kenai.constantine.Constant;
 import com.kenai.constantine.ConstantSet;
 import com.kenai.constantine.platform.Errno;
-import org.jruby.ext.posix.util.Platform;
+import jnr.posix.util.Platform;
 import org.python.core.ClassDictInit;
 import org.python.core.Py;
 import org.python.core.PyDictionary;
--- jython-2.5.4-RC1.orig/src/org/python/modules/posix/PosixModule.java
+++ jython-2.5.4-RC1/src/org/python/modules/posix/PosixModule.java
@@ -17,10 +17,10 @@ import java.security.SecureRandom;
 import java.util.Iterator;
 import java.util.Map;
-import org.jruby.ext.posix.FileStat;
-import org.jruby.ext.posix.POSIX;
-import org.jruby.ext.posix.POSIXFactory;
-import org.jruby.ext.posix.util.Platform;
+import jnr.posix.FileStat;
+import jnr.posix.POSIX;
+import jnr.posix.POSIXFactory;
+import jnr.posix.util.Platform;
 import org.python.core.ClassDictInit;
 import org.python.core.Py;
--- jython-2.5.4-RC1.orig/src/org/python/modules/posix/PyStatResult.java
+++ jython-2.5.4-RC1/src/org/python/modules/posix/PyStatResult.java
@@ -1,7 +1,7 @@
 /* Copyright (c) Jython Developers */
 package org.python.modules.posix;
-import org.jruby.ext.posix.FileStat;
+import jnr.posix.FileStat;
 import org.python.core.ArgParser;
 import org.python.core.Py;
--- jython-2.5.4-RC1.orig/src/org/python/modules/posix/PythonPOSIXHandler.java
+++ jython-2.5.4-RC1/src/org/python/modules/posix/PythonPOSIXHandler.java
@@ -1,14 +1,16 @@
 /* Copyright (c) Jython Developers */
 package org.python.modules.posix;
-import com.kenai.constantine.platform.Errno;
+//import com.kenai.constantine.platform.Errno;
+import jnr.constants.platform.Errno;
+import static com.kenai.constantine.platform.Errno.*;
 import java.io.File;
 import java.io.InputStream;
 import java.io.PrintStream;
-import org.jruby.ext.posix.POSIX;
-import org.jruby.ext.posix.POSIXHandler;
+import jnr.posix.POSIX;
+import jnr.posix.POSIXHandler;
 import org.python.core.imp;
 import org.python.core.Options;
@@ -21,9 +23,14 @@ import org.python.core.PyObject;
 public class PythonPOSIXHandler implements POSIXHandler {
     public void error(Errno error, String extraData) {
+	com.kenai.constantine.platform.Errno oldError=com.kenai.constantine.platform.Errno.valueOf(1);
         // XXX: extraData (filename) could have been unicode!
         // http://bugs.jython.org/issue1825
-        throw Py.OSError(error, Py.newString(extraData));
+	// Have to translate from old Errno enum class to new Errno enum class.
+	// Patch by Nils Ulltveit-Moe for Debian.
+	oldError=oldError.values()[error.ordinal()];
+        throw Py.OSError(oldError, Py.newString(extraData));
     public void unimplementedError(String methodName) {
--- jython-2.5.4-RC1.orig/tests/java/org/python/core/PySystemStateTest.java
+++ jython-2.5.4-RC1/tests/java/org/python/core/PySystemStateTest.java
@@ -7,7 +7,7 @@ import java.net.URLStreamHandler;
 import junit.framework.TestCase;
-import org.jruby.ext.posix.util.Platform;
+import jnr.posix.util.Platform;
 public class PySystemStateTest extends TestCase {
This is the maintainer address of Debian's Java team
Please use
debian-j...@lists.debian.org for discussions and questions.

Reply via email to