From ab5c02d538fe7dac52aac6b481ea295a83371839 Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Date: Mon, 17 Jan 2022 07:44:10 -0800 Subject: is_system_path: return False if path is None (#28403) --- lib/spack/spack/test/util/environment.py | 2 ++ lib/spack/spack/util/environment.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/test/util/environment.py b/lib/spack/spack/test/util/environment.py index 233fc0ba84..d5b9d683b7 100644 --- a/lib/spack/spack/test/util/environment.py +++ b/lib/spack/spack/test/util/environment.py @@ -22,6 +22,8 @@ def prepare_environment_for_tests(): def test_is_system_path(): assert(envutil.is_system_path('/usr/bin')) assert(not envutil.is_system_path('/nonsense_path/bin')) + assert(not envutil.is_system_path('')) + assert(not envutil.is_system_path(None)) test_paths = ['/usr/bin', diff --git a/lib/spack/spack/util/environment.py b/lib/spack/spack/util/environment.py index f0457c27b8..e0f0cbec2f 100644 --- a/lib/spack/spack/util/environment.py +++ b/lib/spack/spack/util/environment.py @@ -59,7 +59,7 @@ def is_system_path(path): Returns: True or False """ - return os.path.normpath(path) in system_dirs + return path and os.path.normpath(path) in system_dirs def filter_system_paths(paths): -- cgit v1.2.3-60-g2f50