This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Path.glob() on case-insensitive Posix filesystems
Type: behavior Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: hynek, ned.deily, pitrou, python-dev, ronaldoussoren
Priority: low Keywords:

Created on 2013-11-22 17:49 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg203820 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-11-22 17:49
test_glob fails under OS X:

======================================================================
FAIL: test_glob (test.test_pathlib.PosixPathTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.murray-snowleopard/build/Lib/test/test_pathlib.py", line 1615, in test_glob
    self.assertEqual(set(p.glob("FILEa")), set())
AssertionError: Items in the first set but not the second:
PosixPath('/Users/buildbot/buildarea/3.x.murray-snowleopard/build/build/test_python_39872/@test_39872_tmp/FILEa')


In that test, "FILEa" doesn't exist but "fileA" does.  glob() uses a shortcut when there's no wildcard: it calls .exists() instead of checking the name is inside listdir().  Unfortunately here, the filesystem is insensitive and Path("FILEa").exists() will return True.

However, p.glob("FILEa*") will really return nothing (at least I think so, I don't have a Mac to test), so this is a bit inconsistent.


If we decide the inconsistency is ok, I must then change the test to not exercise it :)
msg203881 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-22 21:14
New changeset cd09766bb18f by Brett Cannon in branch 'default':
Issue #19718: Add a case-insensitive FS check to test.support to use
http://hg.python.org/cpython/rev/cd09766bb18f
msg203883 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-11-22 21:18
FWIW, it looks like Path.glob() is behaving the same as the default shell (bash 3.2 on OS X 10.6.8):

Python 3.4.0a4+ (default:cce14bc9b675, Nov 22 2013, 13:01:47)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathlib
>>> p = pathlib.Path(".")
>>> list(p.glob("fileA"))
[PosixPath('fileA')]
>>> list(p.glob("file*"))
[PosixPath('fileA')]
>>> list(p.glob("fileA*"))
[PosixPath('fileA')]
>>> list(p.glob("FILE*"))
[]
>>> list(p.glob("FILEa*"))
[]
>>> list(p.glob("FILEa"))
[PosixPath('FILEa')]
>>> list(p.glob("FILEA"))
[PosixPath('FILEA')]

$ ls .
fileA
$ ls fileA
fileA
$ ls file*
fileA
$ ls fileA*
fileA
$ ls FILE*
ls: FILE*: No such file or directory
$ ls FILEa*
ls: FILEa*: No such file or directory
$ ls FILEa
FILEa
$ ls FILEA
FILEA
msg203885 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-11-22 21:26
New changeset 4734f6e2fd2f by Antoine Pitrou in branch 'default':
Issue #19718: add one more globbing test under POSIX
http://hg.python.org/cpython/rev/4734f6e2fd2f
msg203886 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-11-22 21:26
> FWIW, it looks like Path.glob() is behaving the same as the default 
> shell (bash 3.2 on OS X 10.6.8)

Thanks, we're in good company then (or at least we're not alone :-)).

Do you think I should fix this issue as fixed now?
msg203887 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-11-22 21:33
test_pathlib now passes.  I'd say it's fixed until someone claims otherwise.
msg203890 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-11-22 21:34
Ok, thanks (and thanks Brett for writing and testing the patch)!
History
Date User Action Args
2022-04-11 14:57:54adminsetgithub: 63917
2013-11-22 21:34:56pitrousetstatus: open -> closed
resolution: fixed
messages: + msg203890

stage: resolved
2013-11-22 21:33:58ned.deilysetmessages: + msg203887
2013-11-22 21:26:51pitrousetmessages: + msg203886
2013-11-22 21:26:11python-devsetmessages: + msg203885
2013-11-22 21:18:15ned.deilysetmessages: + msg203883
2013-11-22 21:14:24python-devsetnosy: + python-dev
messages: + msg203881
2013-11-22 17:49:42pitroucreate