about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-10-17 00:34:32 +0000
committerbors <bors@rust-lang.org>2017-10-17 00:34:32 +0000
commit90691c8c1f8b4ece2a4f831a130ae087056b0083 (patch)
tree900923f73be49d980752485af4cc8f456796931e
parent5618aba38058dc700437b74cca52d139db1b337c (diff)
parentbd8497884c2863a10b6d67855bd90d40783ce2da (diff)
downloadrust-90691c8c1f8b4ece2a4f831a130ae087056b0083.tar.gz
rust-90691c8c1f8b4ece2a4f831a130ae087056b0083.zip
Auto merge of #45138 - johnthagen:future_imports, r=nikomatsakis
Add more __future__ imports to increase compatibility with Python 3 in bootstrap

The functionality of the  `__future__` imports are described [here](https://docs.python.org/3/library/__future__.html).

 These will help ensure the bootstrap code stays compatible with Python 3. If changes are made in the future that use absolute imports, division, or the `print` function, this will be ensure that running it under Python 2 will pass or fail the same way as Python 3.

`Option` is made a [new-style class](https://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes), so that it behaves the same way in Python 2 and 3.

The `__future__ unicode_literals` import is not used, because that can change the semantics of the code in Python 2 in unwanted ways. For more information see [this article](http://python-future.org/unicode_literals.html).
-rw-r--r--src/bootstrap/bootstrap.py2
-rw-r--r--src/bootstrap/bootstrap_test.py1
-rwxr-xr-xsrc/bootstrap/configure.py3
3 files changed, 4 insertions, 2 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 64f76aa2ef4..842144ff1ea 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -8,7 +8,7 @@
 # option. This file may not be copied, modified, or distributed
 # except according to those terms.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import argparse
 import contextlib
 import datetime
diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py
index 32ea4b4abe6..4db7e2ec016 100644
--- a/src/bootstrap/bootstrap_test.py
+++ b/src/bootstrap/bootstrap_test.py
@@ -10,6 +10,7 @@
 
 """Bootstrap tests"""
 
+from __future__ import absolute_import, division, print_function
 import os
 import doctest
 import unittest
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index 7b43de6a322..42425a164a2 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -11,6 +11,7 @@
 
 # ignore-tidy-linelength
 
+from __future__ import absolute_import, division, print_function
 import sys
 import os
 rust_dir = os.path.dirname(os.path.abspath(__file__))
@@ -20,7 +21,7 @@ sys.path.append(os.path.join(rust_dir, "src", "bootstrap"))
 import bootstrap
 
 
-class Option:
+class Option(object):
     def __init__(self, name, rustbuild, desc, value):
         self.name = name
         self.rustbuild = rustbuild