From 3f5152d212898a6e1b6b124c9d5a8287f7b64bb7 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Thu, 20 Apr 2017 21:23:58 +0000 Subject: [PATCH] Fix Python 2 vs 3 incompatability with dict.items() vs iteritems() llvm-svn: 300895 --- clang/tools/clang-format/git-clang-format | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/tools/clang-format/git-clang-format b/clang/tools/clang-format/git-clang-format index 12146bf..3d1ba8a 100755 --- a/clang/tools/clang-format/git-clang-format +++ b/clang/tools/clang-format/git-clang-format @@ -345,8 +345,13 @@ def run_clang_format_and_save_to_tree(changed_lines, revision=None, """Run clang-format on each file and save the result to a git tree. Returns the object ID (SHA-1) of the created tree.""" + def iteritems(container): + try: + return container.iteritems() # Python 2 + except AttributeError: + return container.items() # Python 3 def index_info_generator(): - for filename, line_ranges in changed_lines.viewitems(): + for filename, line_ranges in iteritems(changed_lines): if revision: git_metadata_cmd = ['git', 'ls-tree', '%s:%s' % (revision, os.path.dirname(filename)), -- 2.7.4