Skip to content

Commit d3c39d8

Browse files
committed
Fix regression with literal start pattern and multiple patterns in glob
- Regression for root level literal matches in `glob`. - Bug where `glob` would mistakenly abort if a pattern started with a literal file or directory and could not match a file or directory. This caused subsequent patterns in the chain to not get evaluated.
1 parent 9bd55a7 commit d3c39d8

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

docs/src/markdown/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 4.3.1
4+
5+
- **FIX**: Regression for root level literal matches in `glob`.
6+
- **FIX**: Bug where `glob` would mistakenly abort if a pattern started with a literal file or directory and could not match a file or directory. This caused subsequent patterns in the chain to not get evaluated.
7+
38
## 4.3.0
49

510
- **NEW**: Add `CASE` flag which allows for case sensitive paths on Linux, macOS, and Windows. Windows drive letters and UNC `//host-name/share-name/` portion are still treated insensitively, but all directories will be treated with case sensitivity.

wcmatch/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,5 +186,5 @@ def parse_version(ver, pre=False):
186186
return Version(major, minor, micro, release, pre, post, dev)
187187

188188

189-
__version_info__ = Version(4, 3, 0, "final")
189+
__version_info__ = Version(4, 3, 1, "final")
190190
__version__ = __version_info__._get_canonical()

wcmatch/glob.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ def _glob(self, curdir, this, rest):
373373
else:
374374
yield path, is_dir
375375

376-
def _get_starting_paths(self, curdir):
376+
def _get_starting_paths(self, curdir, dir_only):
377377
"""
378378
Get the starting location.
379379
@@ -391,7 +391,9 @@ def _get_starting_paths(self, curdir):
391391
dirname = os.path.dirname(fullpath)
392392
if basename:
393393
matcher = self._get_matcher(basename)
394-
results = [(os.path.basename(name), is_dir) for name, is_dir in self._glob_dir(dirname, matcher, self)]
394+
results = [
395+
(os.path.basename(name), is_dir) for name, is_dir in self._glob_dir(dirname, matcher, dir_only)
396+
]
395397

396398
return results
397399

@@ -422,18 +424,14 @@ def glob(self):
422424

423425
# Abort if we cannot find the drive, or if current directory is empty
424426
if not curdir or (this.is_drive and not os.path.lexists(curdir)):
425-
return
427+
continue
426428

427429
# Make sure case matches, but running case insensitive
428430
# on a case sensitive file system may return more than
429431
# one starting location.
430-
results = [(curdir, True)] if this.is_drive else self._get_starting_paths(curdir)
432+
results = [(curdir, True)] if this.is_drive else self._get_starting_paths(curdir, dir_only)
431433
if not results:
432-
if not dir_only:
433-
# There is no directory with this name,
434-
# but we have a file and no directory restriction
435-
yield self.format_path(curdir, False, dir_only)
436-
return
434+
continue
437435

438436
if this.dir_only:
439437
# Glob these directories if they exists

0 commit comments

Comments
 (0)