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
diff --git a/clang/utils/analyzer/CmpRuns.py b/clang/utils/analyzer/CmpRuns.py
index 87d5eda..be50349 100755
--- a/clang/utils/analyzer/CmpRuns.py
+++ b/clang/utils/analyzer/CmpRuns.py
@@ -298,10 +298,10 @@
combined_data['PathsLength'].append(diagnostic.getPathLength())
for stat in results.stats:
- for key, value in stat.iteritems():
+ for key, value in stat.items():
combined_data[key].append(value)
combined_stats = {}
- for key, values in combined_data.iteritems():
+ for key, values in combined_data.items():
combined_stats[str(key)] = {
"max": max(values),
"min": min(values),
diff --git a/clang/utils/analyzer/SATestBuild.py b/clang/utils/analyzer/SATestBuild.py
index 70c425d..1c96cd8 100755
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -583,8 +583,7 @@
# Iterate and find the differences.
NumDiffs = 0
- PairList = zip(RefList, NewList)
- for P in PairList:
+ for P in zip(RefList, NewList):
RefDir = P[0]
NewDir = P[1]