Fix broken commit c9fd0d83.

This commit is contained in:
Catherine 2023-08-22 17:06:09 +00:00
parent c9fd0d8391
commit 7714ce329a

View file

@ -33,8 +33,8 @@ class BuildPlan:
forward slashes (``/``). forward slashes (``/``).
""" """
assert isinstance(filename, str) and filename not in self.files assert isinstance(filename, str) and filename not in self.files
if (pathlib.PurePosixPath(filename).is_absolute or if (pathlib.PurePosixPath(filename).is_absolute() or
pathlib.PureWindowsPath(filename).is_absolute): pathlib.PureWindowsPath(filename).is_absolute()):
raise ValueError(f"Filename {filename!r} must not be an absolute path") raise ValueError(f"Filename {filename!r} must not be an absolute path")
self.files[filename] = content self.files[filename] = content
@ -83,7 +83,7 @@ class BuildPlan:
filename = pathlib.Path(filename) filename = pathlib.Path(filename)
# Forbid parent directory components and absolute paths completely to avoid # Forbid parent directory components and absolute paths completely to avoid
# the possibility of writing outside the build root. # the possibility of writing outside the build root.
assert not filename.is_absolute and ".." not in filename.parts assert not filename.is_absolute() and ".." not in filename.parts
dirname = os.path.dirname(filename) dirname = os.path.dirname(filename)
if dirname: if dirname:
os.makedirs(dirname, exist_ok=True) os.makedirs(dirname, exist_ok=True)