is_system_path: return False if path is None (#28403)

This commit is contained in:
Tamara Dahlgren 2022-01-17 07:44:10 -08:00 committed by GitHub
parent 7e3677db6f
commit f238835b65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,8 @@ def prepare_environment_for_tests():
def test_is_system_path(): def test_is_system_path():
assert(envutil.is_system_path('/usr/bin')) assert(envutil.is_system_path('/usr/bin'))
assert(not envutil.is_system_path('/nonsense_path/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', test_paths = ['/usr/bin',

View File

@ -59,7 +59,7 @@ def is_system_path(path):
Returns: Returns:
True or False 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): def filter_system_paths(paths):