Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more __future__ imports to increase compatibility with Python 3 in bootstrap #45138

Merged
merged 2 commits into from
Oct 17, 2017
Merged

Add more __future__ imports to increase compatibility with Python 3 in bootstrap #45138

merged 2 commits into from
Oct 17, 2017

Conversation

johnthagen
Copy link
Contributor

@johnthagen johnthagen commented Oct 9, 2017

The functionality of the __future__ imports are described here.

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, 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.

…e Option from object to make it a new-style class for Python 3 compatibility.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@Mark-Simulacrum
Copy link
Member

r? @aidanhs -- you've reviewed Python in the past. I'm not really opposed to this as long as it keeps the same lower-bound on compatibility.

@johnthagen
Copy link
Contributor Author

I'll await feedback from @aidanhs. This should not change the lower-bound of compatibility, which is still Python 2.7.

@nikomatsakis
Copy link
Contributor

@bors r+

If I'm not mistaken, with the exception of "print function" (which we already depended on), all of these changes are pretty long-standing migrations in Python-land, in the sense that I remember them from my days writing Python like 10 years ago. ;)

@bors
Copy link
Contributor

bors commented Oct 10, 2017

📌 Commit 49a73d0 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 11, 2017

⌛ Testing commit 49a73d0 with merge 369710094062b176057dde172200e1c72f510a9a...

@bors
Copy link
Contributor

bors commented Oct 11, 2017

💔 Test failed - status-travis

@kennytm
Copy link
Member

kennytm commented Oct 11, 2017

@bors retry

This was referenced Oct 11, 2017
@aidanhs aidanhs added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 12, 2017
bors added a commit that referenced this pull request Oct 12, 2017
[WIP] Rollup of 10 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45163, #45166, #45172, #45190, #45231
- Failed merges: #45138
bors added a commit that referenced this pull request Oct 12, 2017
Rollup of 9 pull requests

- Successful merges: #44989, #45005, #45049, #45105, #45121, #45166, #45172, #45190, #45231
- Failed merges: #45138
@bors
Copy link
Contributor

bors commented Oct 13, 2017

☔ The latest upstream changes (presumably #45233) made this pull request unmergeable. Please resolve the merge conflicts.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 14, 2017
@nikomatsakis
Copy link
Contributor

@johnthagen needs rebase

@johnthagen
Copy link
Contributor Author

@nikomatsakis Conflicts have been resovled

@aidanhs
Copy link
Member

aidanhs commented Oct 16, 2017

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 16, 2017

📌 Commit bd84978 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 17, 2017

⌛ Testing commit bd84978 with merge 90691c8...

bors added a commit that referenced this pull request Oct 17, 2017
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).
@bors
Copy link
Contributor

bors commented Oct 17, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 90691c8 to master...

@bors bors merged commit bd84978 into rust-lang:master Oct 17, 2017
@johnthagen johnthagen deleted the future_imports branch October 17, 2017 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants