Title: glob.glob('valid\\path\\') returns [] on Windows
Type: Severity: normal
Components: Versions: Jython 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: kaneg, pekka.klarck, zyasoft
Priority: urgent Keywords:

Created on 2015-01-15.22:55:45 by pekka.klarck, last changed 2015-02-11.22:11:45 by zyasoft.

msg9404 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-01-15.22:55:44
Jython 2.7b4 (default:bfc775b6c48d, Jan 9 2015, 04:16:03)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_25
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob
>>> glob.glob('c:\\temp')
>>> glob.glob('c:\\temp\\')

Having a trailing backspace is not a problem with Jython 2.5 or any Python version.
msg9453 (view) Author: Jim Baker (zyasoft) Date: 2015-01-24.00:22:19
So this is not an issue for a trailing slash on Windows, just a trailing backslash. Interesting difference.
msg9461 (view) Author: Jim Baker (zyasoft) Date: 2015-01-28.19:11:13
Blocker for beta 4
msg9469 (view) Author: Kane Gong (kaneg) Date: 2015-01-31.07:13:04
After reading source code, it was related to os.lstat and os.stat changes in PosixModule which was made on 2/29/2014 and 4/25/2014:
            String absolutePath = absolutePath(path);

            // round tripping from a string to a file to a string loses
            // trailing slashes so add them back back in to get correct posix.lstat
            // behaviour if path is not a directory.
            if (asPath(path).endsWith(File.separator)) {
                absolutePath = absolutePath + File.separator;
            return PyStatResult.fromFileStat(posix.lstat(absolutePath));

According to the change, it will apppend a backslash(For Windows) to the absolute path if the origin path ends with a backslash. But the posix.lstat will report error if the path ends with a backslash. 
Not sure it's an issue for posix implemation in jnr-posix or the path should not be appended a backslash.
msg9473 (view) Author: Jim Baker (zyasoft) Date: 2015-02-02.20:20:12
The specific issue raised here seems to be fixed as of, however, there is one related failing test still in test_glob to be investigated, test_glob_unicode_directory_with_trailing_slash.

@Kane, thanks for your investigation as well. I have completely changed how we do stat on Windows, plus absolute path calculations, so that we follow closer Java 7 Path support and don't use JNR. (Great package, but I prefer not to have a JNI dependency if possible.)
msg9492 (view) Author: Jim Baker (zyasoft) Date: 2015-02-07.01:30:33
test_glob now works as of
Date User Action Args
2015-02-11 22:11:45zyasoftsetstatus: pending -> closed
2015-02-07 01:30:34zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg9492
2015-02-02 20:20:12zyasoftsetmessages: + msg9473
2015-01-31 07:13:05kanegsetnosy: + kaneg
messages: + msg9469
2015-01-28 19:11:47zyasoftsetassignee: zyasoft
2015-01-28 19:11:13zyasoftsetpriority: urgent
messages: + msg9461
2015-01-24 00:22:19zyasoftsetresolution: accepted
messages: + msg9453
nosy: + zyasoft
2015-01-15 22:55:45pekka.klarckcreate