wcmatch: glob.glob fails on absolute paths
Shell globing can accept an absolute path:
$ echo /path/to/dir/file_*.ext
/path/to/dir/file_name.ext
and the entire path is returned.
python3 glob.glob
matches this behaviour:
>>> from glob import glob
>>> glob("/path/to/dir/file_*.ext")
['/path/to/dir/file_name.ext']
wcmatch.glob.glob
doesn’t match this behaviour: instead returning nothing.
>>> from wcmatch.glob import glob
>>> glob("/path/to/dir/file_*.ext")
[]
This can be worked around with root_dir=...
or chdir()
.
But then only the basename is returned not the full path, and extra steps must be taken to reintroduce this component.
>>> glob("file_*.ext", root_dir="/path/to/dir/")
['file_name.ext']
>>> chdir("/path/to/dir/")
>>> glob("file_*.ext")
['file_name.ext']
Ideally wcmatch.glob.glob
would match the behaviour of shell
and python3 glob.glob
>>> from wcmatch.glob import glob
>>> glob("/path/to/dir/file_*.ext")
['/path/to/dir/file_name.ext']
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (10 by maintainers)
@gir-bot add S: more-info-needed
Considering that our tests actually test absolute paths, I’m suspecting there is something locally that is missing from this bug report. I’ve tried the same thing and have no issues:
This is the latest
wcmatch
, Python 3.9.1.