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).
This commit is contained in:
bors 2017-10-17 00:34:32 +00:00
commit 90691c8c1f
3 changed files with 4 additions and 2 deletions

View file

@ -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

View file

@ -10,6 +10,7 @@
"""Bootstrap tests"""
from __future__ import absolute_import, division, print_function
import os
import doctest
import unittest

View file

@ -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