Skip to content

Commit

Permalink
Handle _initial_path_exists more explicitly in select_special()
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale committed Feb 8, 2025
1 parent e9fa3ac commit 46429ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Lib/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def escape(pathname):
_special_parts = ('', '.', '..')
_dir_open_flags = os.O_RDONLY | getattr(os, 'O_DIRECTORY', 0)
_no_recurse_symlinks = object()
_initial_path_exists = [] # falsy sentinel
_initial_path_exists = object()


def translate(pat, *, recursive=False, include_hidden=False, seps=None):
Expand Down Expand Up @@ -277,7 +277,9 @@ def select_special(path, dir_fd=None, rel_path=None, exists=False):
path = self.concat_path(path, part)
if dir_fd is not None:
rel_path = self.concat_path(rel_path, part)
return select_next(path, dir_fd, rel_path, bool(exists))
if exists is _initial_path_exists:
exists = False
return select_next(path, dir_fd, rel_path, exists)
return select_special

def literal_selector(self, part, parts):
Expand Down

0 comments on commit 46429ad

Please sign in to comment.