Skip to content

Commit 36f508f

Browse files
authored
fix: filenames can contain special glob characters (#1405)
* Fix globbing of filenames that contain special glob characters * glob the path as well as the filename
1 parent 774c364 commit 36f508f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

coverage/data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def combinable_files(data_file, data_paths=None):
7070
if os.path.isfile(p):
7171
files_to_combine.append(os.path.abspath(p))
7272
elif os.path.isdir(p):
73-
pattern = os.path.join(os.path.abspath(p), f"{local}.*")
73+
pattern = glob.escape(os.path.join(os.path.abspath(p), local)) +".*"
7474
files_to_combine.extend(glob.glob(pattern))
7575
else:
7676
raise NoDataError(f"Couldn't combine from non-existent path '{p}'")

coverage/sqldata.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,8 @@ def erase(self, parallel=False):
774774
file_be_gone(self._filename)
775775
if parallel:
776776
data_dir, local = os.path.split(self._filename)
777-
localdot = local + ".*"
778-
pattern = os.path.join(os.path.abspath(data_dir), localdot)
777+
local_abs_path = os.path.join(os.path.abspath(data_dir), local)
778+
pattern = glob.escape(local_abs_path) + ".*"
779779
for filename in glob.glob(pattern):
780780
if self._debug.should("dataio"):
781781
self._debug.write(f"Erasing parallel data file {filename!r}")

0 commit comments

Comments
 (0)