diff options
author | teor <teor@torproject.org> | 2019-12-12 15:58:51 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-12-12 15:58:51 +1000 |
commit | 1619f14a0420b0a57d65b9adeab8e8a4ef222b3a (patch) | |
tree | e58abb1dd7d9bae4d48ca00fb7b10b837d952a67 /scripts | |
parent | a38014e5c6fa7955e9af61b42eddb2bc9edc29a9 (diff) | |
download | tor-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')
22 files changed, 100 insertions, 6 deletions
diff --git a/scripts/codegen/fuzzing_include_am.py b/scripts/codegen/fuzzing_include_am.py index a944584453..aa3ba49a73 100755 --- a/scripts/codegen/fuzzing_include_am.py +++ b/scripts/codegen/fuzzing_include_am.py @@ -1,5 +1,10 @@ #!/usr/bin/python +# Future imports for Python 2.7, mandatory in 3.0 +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + FUZZERS = """ consensus descriptor diff --git a/scripts/codegen/gen_server_ciphers.py b/scripts/codegen/gen_server_ciphers.py index 5d326f8b9e..dd295b7f7d 100755 --- a/scripts/codegen/gen_server_ciphers.py +++ b/scripts/codegen/gen_server_ciphers.py @@ -8,6 +8,11 @@ # # Run it on all the files in your openssl include directory. +# 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 import sys diff --git a/scripts/codegen/get_mozilla_ciphers.py b/scripts/codegen/get_mozilla_ciphers.py index f23f2f1e6f..d149c71c27 100755 --- a/scripts/codegen/get_mozilla_ciphers.py +++ b/scripts/codegen/get_mozilla_ciphers.py @@ -10,6 +10,11 @@ # It takes two arguments: the location of a firefox source directory, and the # location of an openssl source directory. +# 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 import re import sys diff --git a/scripts/codegen/makedesc.py b/scripts/codegen/makedesc.py index efca4dda9a..7d8177f469 100644 --- a/scripts/codegen/makedesc.py +++ b/scripts/codegen/makedesc.py @@ -9,6 +9,11 @@ # I've used this to make inputs for unit tests. I wouldn't suggest # using it for anything else. +# 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 base64 import binascii import ctypes diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index a773fd0fff..a9a6eb25bd 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -9,6 +9,11 @@ % add_c_file.py ./src/feature/dirauth/ocelot.c """ +# 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 import re import time diff --git a/scripts/maint/annotate_ifdef_directives.py b/scripts/maint/annotate_ifdef_directives.py index 102128bfa0..cd70b55c8c 100755 --- a/scripts/maint/annotate_ifdef_directives.py +++ b/scripts/maint/annotate_ifdef_directives.py @@ -57,6 +57,11 @@ Note that only #else and #endif lines are annotated. Existing comments on those lines are removed. """ +# 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 # Any block with fewer than this many lines does not need annotations. diff --git a/scripts/maint/checkIncludes.py b/scripts/maint/checkIncludes.py index 926b201b35..2ca46347f0 100755 --- a/scripts/maint/checkIncludes.py +++ b/scripts/maint/checkIncludes.py @@ -5,6 +5,11 @@ # functionality. This is a stub file that exists so that older git # hooks will know where to look. +# 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 sys, os dirname = os.path.split(sys.argv[0])[0] diff --git a/scripts/maint/format_changelog.py b/scripts/maint/format_changelog.py index 97a6ce938b..5f04a44ef6 100755 --- a/scripts/maint/format_changelog.py +++ b/scripts/maint/format_changelog.py @@ -9,7 +9,11 @@ # To run it, pipe a section of the changelog (starting with "Changes # in Tor 0.x.y.z-alpha" through the script.) +# 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 import re import sys diff --git a/scripts/maint/lintChanges.py b/scripts/maint/lintChanges.py index 82c118f07e..88a865a572 100755 --- a/scripts/maint/lintChanges.py +++ b/scripts/maint/lintChanges.py @@ -1,7 +1,10 @@ #!/usr/bin/python +# Future imports for Python 2.7, mandatory in 3.0 +from __future__ import division from __future__ import print_function -from __future__ import with_statement +from __future__ import unicode_literals + import sys import re import os diff --git a/scripts/maint/locatemissingdoxygen.py b/scripts/maint/locatemissingdoxygen.py index 797bf8176f..9e58bd3477 100755 --- a/scripts/maint/locatemissingdoxygen.py +++ b/scripts/maint/locatemissingdoxygen.py @@ -7,6 +7,11 @@ to highlight the undocumented stuff. """ +# 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 import re import shutil 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, diff --git a/scripts/maint/rectify_include_paths.py b/scripts/maint/rectify_include_paths.py index 1140e8cd22..111cf816ce 100755 --- a/scripts/maint/rectify_include_paths.py +++ b/scripts/maint/rectify_include_paths.py @@ -1,5 +1,10 @@ #!/usr/bin/python +# 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 import os.path import re diff --git a/scripts/maint/redox.py b/scripts/maint/redox.py index 203cce0107..171c6d9699 100755 --- a/scripts/maint/redox.py +++ b/scripts/maint/redox.py @@ -29,6 +29,14 @@ # "mv fname.c.newdoc fname.c". Otherwise, you'll need to merge # the parts you like by hand. +# 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 +import sys + # Which files should we ignore warning from? Mostly, these are external # files that we've snarfed in from somebody else, whose C we do no intend # to document for them. @@ -52,9 +60,6 @@ ADD_DOCDOCS_TO_TYPES += [ 'variable', ] # ==================== # The rest of this should not need hacking. -import re -import sys - KINDS = [ "type", "field", "typedef", "define", "function", "variable", "enumeration" ] diff --git a/scripts/maint/rename_c_identifier.py b/scripts/maint/rename_c_identifier.py index 213172d913..6e0c1d8cf1 100755 --- a/scripts/maint/rename_c_identifier.py +++ b/scripts/maint/rename_c_identifier.py @@ -11,6 +11,11 @@ Helpful script to replace one or more C identifiers, and optionally generate a commit message explaining what happened. """ +# 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 argparse import fileinput import os diff --git a/scripts/maint/sortChanges.py b/scripts/maint/sortChanges.py index 44dd0dc41f..2e049b1e53 100755 --- a/scripts/maint/sortChanges.py +++ b/scripts/maint/sortChanges.py @@ -7,7 +7,11 @@ changelog. """ +# 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 import sys diff --git a/scripts/maint/update_versions.py b/scripts/maint/update_versions.py index 706a93b6a2..07de1c343a 100755 --- a/scripts/maint/update_versions.py +++ b/scripts/maint/update_versions.py @@ -1,6 +1,9 @@ #!/usr/bin/env python +# 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 io import os diff --git a/scripts/test/appveyor-irc-notify.py b/scripts/test/appveyor-irc-notify.py index cfe0afe7ae..598a68f47d 100644 --- a/scripts/test/appveyor-irc-notify.py +++ b/scripts/test/appveyor-irc-notify.py @@ -75,8 +75,10 @@ in Appveyor's YAML: - "python scripts/test/appveyor-irc-notify.py irc.oftc.net:6697 tor-ci failure """ +# Future imports for Python 2.7, mandatory in 3.0 +from __future__ import division from __future__ import print_function -from __future__ import absolute_import +from __future__ import unicode_literals import os import random |