summaryrefslogtreecommitdiff
path: root/scripts/maint/practracker/practracker.py
diff options
context:
space:
mode:
authorTaylor Yu <catalyst@torproject.org>2019-03-22 17:45:06 -0500
committerTaylor Yu <catalyst@torproject.org>2019-03-22 17:51:55 -0500
commit307c156fbe2f70a697afbf5340e40655173125a6 (patch)
tree8ad73af51bc77b81e56296069c524073f3e534d7 /scripts/maint/practracker/practracker.py
parent22e72eeaa78e84ca5b839690628de0db0c287d58 (diff)
downloadtor-307c156fbe2f70a697afbf5340e40655173125a6.tar.gz
tor-307c156fbe2f70a697afbf5340e40655173125a6.zip
Set file encoding in practracker.py
Explicitly set the file encoding to UTF-8 in practracker.py, to avoid problems in some CI environments. Fixes bug 29789; bug not in any released Tor.
Diffstat (limited to 'scripts/maint/practracker/practracker.py')
-rwxr-xr-xscripts/maint/practracker/practracker.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py
index a6e6d0b607..3274bd15f7 100755
--- a/scripts/maint/practracker/practracker.py
+++ b/scripts/maint/practracker/practracker.py
@@ -46,6 +46,13 @@ TOR_TOPDIR = None
#######################################################
+if sys.version_info[0] <= 2:
+ def open_file(fname):
+ return open(fname, 'r')
+else:
+ def open_file(fname):
+ return open(fname, 'r', encoding='utf-8')
+
def consider_file_size(fname, f):
"""Consider file size issues for 'f' and return True if a new issue was found"""
file_size = metrics.get_file_len(f)
@@ -85,7 +92,7 @@ def consider_all_metrics(files_list):
"""Consider metrics for all files, and return True if new issues were found"""
found_new_issues = False
for fname in files_list:
- with open(fname, 'r') as f:
+ with open_file(fname) as f:
found_new_issues |= consider_metrics_for_file(fname, f)
return found_new_issues