Skip to content
Snippets Groups Projects
Unverified Commit 1619f14a authored by teor's avatar teor
Browse files

python: Add __future__ imports for python 3 compatibility

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

Closes ticket 32732.
parent a38014e5
No related branches found
No related tags found
No related merge requests found
Showing
with 95 additions and 5 deletions
#!/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 socket
import struct
import sys
......
#!/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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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,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]
......
......@@ -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
......
#!/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
......
......@@ -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
......
......@@ -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
......
......@@ -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):
......
......@@ -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:
......
......@@ -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
......
# 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,
......
#!/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
......
......@@ -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" ]
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment