From: SourceForge.net <no...@so...> - 2007-02-18 12:01:51
|
Bugs item #1661700, was opened at 2007-02-16 12:28 Message generated for change (Comment added) made by hsk0 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1661700&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Pekka Laukkanen (laukpe) Assigned to: Nobody/Anonymous (nobody) Summary: os.path.abspath raises IOException if drive not accessible Initial Comment: See the example below. Note that d drive on my WinXP is a CD drive and I don't have r drive at all. C:\>d: The device is not ready. C:\>r: The system cannot find the drive specified. C:\>jython Jython 2.2b1 on java1.5.0_10 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import os >>> os.path.abspath('foo') 'C:\\foo' >>> os.path.abspath('r:\\foo') 'R:\\foo' >>> os.path.abspath('d:\\foo') Traceback (innermost last): File "<console>", line 1, in ? File "C:\jython2.2b1\Lib\javapath.py", line 240, in abspath at java.io.WinNTFileSystem.canonicalize0(Native Method) at java.io.Win32FileSystem.canonicalize(Unknown Source) at java.io.File.getCanonicalPath(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source at java.lang.reflect.Method.invoke(Unknown Source) java.io.IOException: java.io.IOException: The device is not ready >>> C:\>python Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.path.abspath('foo') 'C:\\foo' >>> os.path.abspath('r:\\foo') 'r:\\foo' >>> os.path.abspath('d:\\foo') 'd:\\foo' ---------------------------------------------------------------------- Comment By: howard kapustein (hsk0) Date: 2007-02-18 07:01 Message: Logged In: YES user_id=16060 Originator: NO No more exceptions if you apply the patch I provided to #1648449 (os.path.normcase broken in Windows). Problem is os.path is really either dospath, macpath, ntpath, posixpath -- in CPython. In Jython, ...\Lib\javaos.py was always unconditionally loading javapath (a Jython creation): import javapath as path and javapath's isabs() test is very different from ntpath -- javapath calls File(path).isAbsolute() which appears to touch the file system whereas ntpath's isabs() just calls splitdrive() and does a simple string test. In short, javapath does a 'live' test dependent on the state of the underlying OS at that moment, whereas ntpath does a definitional test (does the path meet Windows' criteria for an absolute pathname). NOTE: isabs() is a definitional test in all CPython flavors, independent of the current state of the underlying OS. Check dospath, macpath, ntpath and posixpath. Only javapath relies on the current state of the OS. Needless to say, I prefer my patch to load ${os}path.py :-) ---------------------------------------------------------------------- Comment By: Pekka Laukkanen (laukpe) Date: 2007-02-16 19:54 Message: Logged In: YES user_id=1379331 Originator: YES Bad news: Related problems also in realpath and samefile. Good news: I have a patch ready but want to write some tests for it before submitting. Should get those done tomorrow. ---------------------------------------------------------------------- Comment By: Pekka Laukkanen (laukpe) Date: 2007-02-16 12:30 Message: Logged In: YES user_id=1379331 Originator: YES Probably the best solution for this is catching possible IOException from getCanonicalPath and using getAbsolutePath in that case. Jython 2.2alpha1 used getAbsolutePath and this problem doesn't appear there. The implementation was changed to fix http://jython.org/bugs/1423047 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112867&aid=1661700&group_id=12867 |