summaryrefslogtreecommitdiff
path: root/scripts/maint/practracker
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-12-12 15:58:51 +1000
committerteor <teor@torproject.org>2019-12-12 15:58:51 +1000
commit1619f14a0420b0a57d65b9adeab8e8a4ef222b3a (patch)
treee58abb1dd7d9bae4d48ca00fb7b10b837d952a67 /scripts/maint/practracker
parenta38014e5c6fa7955e9af61b42eddb2bc9edc29a9 (diff)
downloadtor-1619f14a0420b0a57d65b9adeab8e8a4ef222b3a.tar.gz
tor-1619f14a0420b0a57d65b9adeab8e8a4ef222b3a.zip
python: Add __future__ imports for python 3 compatibility
Except for src/ext, which we may not want to modify. Closes ticket 32732.
Diffstat (limited to 'scripts/maint/practracker')
-rwxr-xr-xscripts/maint/practracker/includes.py4
-rw-r--r--scripts/maint/practracker/metrics.py5
-rwxr-xr-xscripts/maint/practracker/practracker.py3
-rwxr-xr-xscripts/maint/practracker/practracker_tests.py5
-rw-r--r--scripts/maint/practracker/problem.py3
-rw-r--r--scripts/maint/practracker/util.py5
6 files changed, 24 insertions, 1 deletions
diff --git a/scripts/maint/practracker/includes.py b/scripts/maint/practracker/includes.py
index ed0e11ef28..fe0f32e253 100755
--- a/scripts/maint/practracker/includes.py
+++ b/scripts/maint/practracker/includes.py
@@ -19,8 +19,10 @@
Advisory .may_include files only result in warnings, rather than errors.
"""
-
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
from __future__ import print_function
+from __future__ import unicode_literals
import fnmatch
import os
diff --git a/scripts/maint/practracker/metrics.py b/scripts/maint/practracker/metrics.py
index 4c62bc2425..ae88b84f31 100644
--- a/scripts/maint/practracker/metrics.py
+++ b/scripts/maint/practracker/metrics.py
@@ -4,6 +4,11 @@
# These are currently ad-hoc string operations and regexps.
# We might want to use a proper static analysis library in the future, if we want to get more advanced metrics.
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import re
def get_file_len(f):
diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py
index 5f26d28cea..e1845c43e3 100755
--- a/scripts/maint/practracker/practracker.py
+++ b/scripts/maint/practracker/practracker.py
@@ -19,7 +19,10 @@ problems in the Tor source, use the --regen flag:
$ python3 --regen ./scripts/maint/practracker/practracker.py .
"""
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
from __future__ import print_function
+from __future__ import unicode_literals
import os, sys
diff --git a/scripts/maint/practracker/practracker_tests.py b/scripts/maint/practracker/practracker_tests.py
index 45719d6cb7..8d0418880c 100755
--- a/scripts/maint/practracker/practracker_tests.py
+++ b/scripts/maint/practracker/practracker_tests.py
@@ -2,6 +2,11 @@
"""Some simple tests for practracker metrics"""
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import unittest
try:
diff --git a/scripts/maint/practracker/problem.py b/scripts/maint/practracker/problem.py
index d21840a213..bee5eeb903 100644
--- a/scripts/maint/practracker/problem.py
+++ b/scripts/maint/practracker/problem.py
@@ -7,7 +7,10 @@ problem is worse than a registered exception so that it only warns when things
get worse.
"""
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
from __future__ import print_function
+from __future__ import unicode_literals
import os.path
import re
diff --git a/scripts/maint/practracker/util.py b/scripts/maint/practracker/util.py
index db02a983f8..c52ca2fbbf 100644
--- a/scripts/maint/practracker/util.py
+++ b/scripts/maint/practracker/util.py
@@ -1,3 +1,8 @@
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
+
import os
# We don't want to run metrics for unittests, automatically-generated C files,