Message2646

Author hsk0
Recipients
Date 2007-02-20.14:26:01
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
javaos unconditionally imports javapath as os.path
This breaks several things as javaos doesn't properly implement several os.path functions, relies on the underlying live system at the moment instead of purely definitional expectations, and fundamentally provides a different model of os.path than CPython does (always loads javapath=os.path, instead of conditionally making os.path=ntpath, posixpath, macpath, etc).

You can see the full details in my comments to the bug
http://sourceforge.net/tracker/index.php?func=detail&aid=1648449&group_id=12867&atid=112867

This patch also fixes
[1661700] os.path.abspath raises IOException if drive not accessible

See my comments on that bug as well for why
http://sourceforge.net/tracker/index.php?func=detail&aid=1661700&group_id=12867&atid=112867

This likely fixes other problems as well.

javaos.py is from Jython 2.2b1
javaoshk.py has my modifications
Here's the diff
--------------------
[~] diff -u javaos.py javaoshk.py
--- javaos.py   2007-02-20 09:06:22.000000000 -0500
+++ javaoshk.py 2007-02-20 09:08:35.000000000 -0500
@@ -28,9 +28,29 @@

 import java
 from java.io import File
-import javapath as path
 from UserDict import UserDict

+# Load the right flavor of os.path
+_osname = None
+_jythonospath = java.lang.System.getProperty('jython.os.path')
+if _jythonospath:
+    _jythonospath =  _jythonospath.lower()
+    if _jythonospath in ['java', 'dos', 'mac', 'nt', 'posix']:
+        _osname = _jythonospath
+if _osname == None:
+    _osname = java.lang.System.getProperty('os.name').lower()
+if _osname == 'nt' or  _osname.startswith('windows'):
+    import ntpath as path
+elif _osname.startswith('mac') and not _osname.endswith('x'):
+    import macpath as path
+elif _osname == 'dos':
+    import dospath as path
+elif (_osname == 'posix') or ((File.pathSeparator == ':') and ('vms' not
+in _osname) and (not _osname.startswith('mac') or _osname.endswith('x'))):
+    import posixpath as path
+else:
+    import javapath as path
+
 class stat_result:
   import stat as _stat
History
Date User Action Args
2008-02-20 17:18:39adminlinkissue1664366 messages
2008-02-20 17:18:39admincreate