From d458974c454ee977dc0bd3b9f1116df7d4037ab2 Mon Sep 17 00:00:00 2001 From: Serge Guelton Date: Tue, 18 Dec 2018 16:04:21 +0000 Subject: Portable Python script across Python version In Python3, dict.items, dict.keys, dict.values, zip, map and filter no longer return lists, they create generator instead. The portability patch consists in forcing an extra `list` call if the result is actually used as a list. `map` are replaced by list comprehension and `filter` by filtered list comprehension. Differential Revision: https://reviews.llvm.org/D55197 llvm-svn: 349501 --- clang/utils/check_cfc/check_cfc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'clang/utils/check_cfc/check_cfc.py') diff --git a/clang/utils/check_cfc/check_cfc.py b/clang/utils/check_cfc/check_cfc.py index 0228f1d6259..aea9bdd6388 100755 --- a/clang/utils/check_cfc/check_cfc.py +++ b/clang/utils/check_cfc/check_cfc.py @@ -98,8 +98,8 @@ def remove_dir_from_path(path_var, directory): PATH""" pathlist = path_var.split(os.pathsep) norm_directory = os.path.normpath(os.path.normcase(directory)) - pathlist = filter(lambda x: os.path.normpath( - os.path.normcase(x)) != norm_directory, pathlist) + pathlist = [x for x in pathlist if os.path.normpath( + os.path.normcase(x)) != norm_directory] return os.pathsep.join(pathlist) def path_without_wrapper(): -- cgit v1.2.3