Issue1975

classification
Title: os.path.isdir fails on network share (windows)
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
process
Status: open Resolution: remind
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, pekka.klarck, pjenvey, wayju
Priority: normal Keywords:

Created on 2012-10-08.21:36:11 by wayju, last changed 2013-02-19.23:12:08 by fwierzbicki.

Messages
msg7472 (view) Author: Wayne Thomson (wayju) Date: 2012-10-08.21:36:10
os.path.isdir returns False for network share while os.listdir returns the contents of the directory. Running os.path.isdir from python returns True for same path.

See below:

Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir('\\\\localhost\\temp')
['aNew Text Document.txt', 'New folder']
>>> os.path.isdir('\\\\localhost\\temp')
False

D:\iE2>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.listdir('\\\\localhost\\temp')
['aNew Text Document.txt', 'New folder']
>>> os.path.isdir('\\\\localhost\\temp')
True
msg7473 (view) Author: Philip Jenvey (pjenvey) Date: 2012-10-08.23:39:08
This may be due to the lack of nt._isdir (it replaces the impl of isdir in ntpath if it exists)

Could you show us the result of this on CPython 2.7?

import genericpath; genericpath.isdir('\\\\localhost\\temp')
msg7474 (view) Author: Wayne Thomson (wayju) Date: 2012-10-09.01:44:54
Thanks for your quick response. In case it matters I am running windows 7.

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import genericpath; genericpath.isdir('\\\\localhost\\temp')
True

Cheers,

Wayne.
msg7479 (view) Author: Wayne Thomson (wayju) Date: 2012-10-18.00:05:44
Hi there. Someone suggested that I try os.stat and os.path.exists. 

In python nt.stat.result is returned and os.path.exists is true. In jython it says 'No such file or directory: '\\\\localhost\\temp' for os.stat. and os.path.exists returns false.

See below.

Thanks,

Wayne.


D:\iE2>jython
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.stat('\\\\localhost\\temp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 2] No such file or directory: '\\\\localhost\\temp'
>>> os.listdir('\\\\localhost\\temp')
['aNew Text Document.txt', 'New folder']
>>> os.path.exists('\\\\localhost\\temp')
False
>>> →


D:\iE2>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.stat('\\\\localhost\\temp')
nt.stat_result(st_mode=16895, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=4096L, st_atime=1349415447L, st_mtime=1349415447L, st_ctime=1349226494L)
>>> os.listdir('\\\\localhost\\temp')
['aNew Text Document.txt', 'New folder']
>>> os.path.exists('\\\\localhost\\temp')
True
>>>
msg7564 (view) Author: Wayne Thomson (wayju) Date: 2013-01-08.00:42:10
Philip did you have any idea about this after I provided the response?

Thanks,

Wayne.
msg7565 (view) Author: Philip Jenvey (pjenvey) Date: 2013-01-08.01:32:25
Thanks for the update, Wayne.

The fact that genericpath.isdir handles this correctly leads me to believe that the problem lies in Jython's internal absolute path expansion handling (which stat uses and isdir relies on stat)

If you could show me the output of yet another function call on this platform, that could confirm my suspicion. Try:

from org.python.core import PySystemState; PySystemState.getPathLazy('\\\\localhost\\temp')
msg7566 (view) Author: Wayne Thomson (wayju) Date: 2013-01-09.00:14:39
Thanks Philip. I ran the previous commands to check that they still return the same results (as it has been a couple of months) and they do. 

Here is the result of the command you requested.

D:\iE2>jython
Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:48:36)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_31
Type "help", "copyright", "credits" or "license" for more information.
>>> from org.python.core import PySystemState; PySystemState.getPathLazy('\\\\localhost\\temp')
u'\\\\localhost\\temp'
>>>
History
Date User Action Args
2013-02-19 23:12:08fwierzbickisetresolution: remind
versions: + Jython 2.5, - 2.5.1, 2.5.2, 2.5.3b2
2013-02-19 23:11:48fwierzbickisetpriority: normal
nosy: + fwierzbicki
2013-01-09 00:14:39wayjusetmessages: + msg7566
2013-01-08 01:32:27pjenveysetmessages: + msg7565
2013-01-08 00:42:10wayjusetmessages: + msg7564
2012-10-23 22:34:57pekka.klarcksetnosy: + pekka.klarck
2012-10-18 00:05:45wayjusetmessages: + msg7479
2012-10-09 01:44:55wayjusetmessages: + msg7474
2012-10-08 23:39:08pjenveysetnosy: + pjenvey
messages: + msg7473
2012-10-08 21:36:11wayjucreate