Browse Source

python: Add __future__ imports for python 3 compatibility

Closes ticket 32731.
teor 3 years ago
parent
commit
f9d27ae30c

+ 3 - 0
lib/chutney/Debug.py

@@ -7,7 +7,10 @@
 #  restrict, so long as you retain the above notice(s) and this license
 #  in all redistributed copies and derived works.  There is no warranty.
 
+# 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 cgitb
 import os

+ 4 - 0
lib/chutney/Host.py

@@ -1,3 +1,7 @@
+# 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 chutney.Util

+ 3 - 1
lib/chutney/Templating.py

@@ -76,8 +76,10 @@
 
 """
 
+# 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 string
 import os

+ 3 - 1
lib/chutney/TorNet.py

@@ -7,8 +7,10 @@
 #  restrict, so long as you retain the above notice(s) and this license
 #  in all redistributed copies and derived works.  There is no warranty.
 
+# 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 cgitb
 import os

+ 3 - 0
lib/chutney/Traffic.py

@@ -20,7 +20,10 @@
 #
 # For example code, see main() below.
 
+# 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
 import socket

+ 4 - 1
lib/chutney/Util.py

@@ -1,4 +1,7 @@
-
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals
 
 def memoized(fn):
     """Decorator: memoize a function."""

+ 4 - 0
lib/chutney/__init__.py

@@ -0,0 +1,4 @@
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals

+ 4 - 0
scripts/chutney_tests/__init__.py

@@ -0,0 +1,4 @@
+# Future imports for Python 2.7, mandatory in 3.0
+from __future__ import division
+from __future__ import print_function
+from __future__ import unicode_literals

+ 5 - 1
scripts/chutney_tests/verify.py

@@ -1,7 +1,11 @@
+# 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 time
 import chutney
 
-
 def run_test(network):
     wait_time = network._dfltEnv['bootstrap_time']
     start_time = time.time()