Skip to content

Commit

Permalink
fix: filenames can contain special glob characters (#1405)
Browse files Browse the repository at this point in the history
* Fix globbing of filenames that contain special glob characters

* glob the path as well as the filename
  • Loading branch information
earthman1 committed Aug 6, 2022
1 parent 774c364 commit 36f508f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion coverage/data.py
Expand Up @@ -70,7 +70,7 @@ def combinable_files(data_file, data_paths=None):
if os.path.isfile(p):
files_to_combine.append(os.path.abspath(p))
elif os.path.isdir(p):
pattern = os.path.join(os.path.abspath(p), f"{local}.*")
pattern = glob.escape(os.path.join(os.path.abspath(p), local)) +".*"
files_to_combine.extend(glob.glob(pattern))
else:
raise NoDataError(f"Couldn't combine from non-existent path '{p}'")
Expand Down
4 changes: 2 additions & 2 deletions coverage/sqldata.py
Expand Up @@ -774,8 +774,8 @@ def erase(self, parallel=False):
file_be_gone(self._filename)
if parallel:
data_dir, local = os.path.split(self._filename)
localdot = local + ".*"
pattern = os.path.join(os.path.abspath(data_dir), localdot)
local_abs_path = os.path.join(os.path.abspath(data_dir), local)
pattern = glob.escape(local_abs_path) + ".*"
for filename in glob.glob(pattern):
if self._debug.should("dataio"):
self._debug.write(f"Erasing parallel data file {filename!r}")
Expand Down

0 comments on commit 36f508f

Please sign in to comment.