Skip to content

Commit 90691c8

Browse files
committed
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).
2 parents 5618aba + bd84978 commit 90691c8

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/bootstrap/bootstrap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# option. This file may not be copied, modified, or distributed
99
# except according to those terms.
1010

11-
from __future__ import print_function
11+
from __future__ import absolute_import, division, print_function
1212
import argparse
1313
import contextlib
1414
import datetime

src/bootstrap/bootstrap_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
"""Bootstrap tests"""
1212

13+
from __future__ import absolute_import, division, print_function
1314
import os
1415
import doctest
1516
import unittest

src/bootstrap/configure.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
# ignore-tidy-linelength
1313

14+
from __future__ import absolute_import, division, print_function
1415
import sys
1516
import os
1617
rust_dir = os.path.dirname(os.path.abspath(__file__))
@@ -20,7 +21,7 @@
2021
import bootstrap
2122

2223

23-
class Option:
24+
class Option(object):
2425
def __init__(self, name, rustbuild, desc, value):
2526
self.name = name
2627
self.rustbuild = rustbuild

0 commit comments

Comments
 (0)