Skip to content

Commit

Permalink
RecordEntry._coerce_path: always convert to PurePath for checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Jul 30, 2024
1 parent 93a6d06 commit feacd55
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions dist_meta/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,16 @@ def _coerce_path(cls, path: PathLike) -> PathLike:
raise ValueError("RecordEntry paths cannot be absolute")

if isinstance(path, pathlib.PurePath):
if path.is_absolute():
# Catch absolute paths from other platform
raise ValueError("RecordEntry paths cannot be absolute")
path = path.as_posix()
if posixpath.isabs(path):
raise ValueError("RecordEntry paths cannot be absolute")
path_p = path
else:
path_p = pathlib.PurePath(path)

if path_p.is_absolute():
# Catch absolute paths from other platform
raise ValueError("RecordEntry paths cannot be absolute")
path = path_p.as_posix()
if posixpath.isabs(path):
raise ValueError("RecordEntry paths cannot be absolute")

return path

Expand Down

0 comments on commit feacd55

Please sign in to comment.