python: Add __future__ imports for python 3 compatibility

Except for src/ext, which we may not want to modify.

Closes ticket 32732.
This commit is contained in:
teor
2019-12-12 15:58:51 +10:00
parent a38014e5c6
commit 1619f14a04
36 changed files with 168 additions and 7 deletions
+5
View File
@@ -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
+5
View File
@@ -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
+5
View File
@@ -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
+5
View File
@@ -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
+5
View File
@@ -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
@@ -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.
+5
View File
@@ -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]
+4
View File
@@ -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
+4 -1
View File
@@ -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
+5
View File
@@ -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
+3 -1
View File
@@ -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
+5
View File
@@ -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):
+3
View File
@@ -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
@@ -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:
+3
View File
@@ -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
+5
View File
@@ -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,
+5
View File
@@ -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
+8 -3
View File
@@ -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" ]
+5
View File
@@ -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
+4
View File
@@ -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
+3
View File
@@ -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
+3 -1
View File
@@ -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