summaryrefslogtreecommitdiffstats
path: root/tools/clang-format
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-04-20 21:23:58 +0000
committerEric Fiselier <eric@efcs.ca>2017-04-20 21:23:58 +0000
commitc85fce858319c43ddec64361e9c130aad84a2761 (patch)
treedb8f96bcec70888103b03105b423e225e942c569 /tools/clang-format
parentbc65dd754b4df9f39cc3e5b4bd4dceb2cc1d3ee0 (diff)
Fix Python 2 vs 3 incompatability with dict.items() vs iteritems()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300895 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/clang-format')
-rwxr-xr-xtools/clang-format/git-clang-format7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/clang-format/git-clang-format b/tools/clang-format/git-clang-format
index 12146bf77c..3d1ba8a3c1 100755
--- a/tools/clang-format/git-clang-format
+++ b/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)),