summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2022-02-03 07:59:33 +0100
committerChristian Stenger <christian.stenger@qt.io>2022-02-04 10:26:01 +0000
commit394bfb508f11f949336723412164a86c185ba024 (patch)
tree69a5e233a448a5b187682fa4ef179ef4c762e18d /scripts
parent0d812cd59b0c26f92f062920650ad59756c0f600 (diff)
downloadqt-creator-394bfb508f11f949336723412164a86c185ba024.tar.gz
Scripts: Fix output for python 3
Change-Id: Ie914e04b25bdd4e41a9d2b3a9002385f5867ad6b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/uichanges.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/uichanges.py b/scripts/uichanges.py
index 0dcc054a8f..126cbfc9a3 100755
--- a/scripts/uichanges.py
+++ b/scripts/uichanges.py
@@ -181,6 +181,15 @@ def diffContext(ctx, old, new):
return report
+
+def stringify(obj):
+ stringTypes = (str, unicode) if sys.version_info.major == 2 else (str)
+ if isinstance(obj, stringTypes):
+ return obj
+ if isinstance(obj, bytes):
+ tmp = obj.decode('cp1252') if platform.system() in ('Microsoft','Windows') else obj.decode()
+ return tmp
+
# --- The main program
oldGenerator = Generator()
@@ -203,21 +212,21 @@ newContextSet = set(newTree.keys())
for c in sorted(oldContextSet.difference(newContextSet)):
report = diffContext(c, oldTree[c], {})
if report:
- print(report.encode('utf-8'))
+ print(stringify(report.encode('utf-8')))
else:
unchangedContexts += 1
for c in sorted(newContextSet.difference(oldContextSet)):
report = diffContext(c, {}, newTree[c])
if report:
- print(report.encode('utf-8'))
+ print(stringify(report.encode('utf-8')))
else:
unchangedContexts += 1
for c in sorted(newContextSet.intersection(oldContextSet)):
report = diffContext(c, oldTree[c], newTree[c])
if report:
- print(report.encode('utf-8'))
+ print(stringify(report.encode('utf-8')))
else:
unchangedContexts += 1