From 8f1be225dd71694d5035d8a938bd6616d69b6de6 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Fri, 10 Jan 2025 11:55:18 +0100 Subject: [PATCH] Executable: allow also pathlib.Path in constructor --- lib/spack/spack/util/executable.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index 9502b0e63f0..6dd35cfd271 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -20,9 +20,9 @@ class Executable: """Class representing a program that can be run on the command line.""" - def __init__(self, name: str) -> None: + def __init__(self, name: Union[str, Path]) -> None: file_path = str(Path(name)) - if sys.platform != "win32" and name.startswith("."): + if sys.platform != "win32" and isinstance(name, str) and name.startswith("."): # pathlib strips the ./ from relative paths so it must be added back file_path = os.path.join(".", file_path)