This repository has been archived by the owner on Nov 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Python 3 compat #66
Open
douglas-raillard-arm
wants to merge
9
commits into
ARM-software:master
Choose a base branch
from
douglas-raillard-arm:py3k
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Python 3 compat #66
douglas-raillard-arm
wants to merge
9
commits into
ARM-software:master
from
douglas-raillard-arm:py3k
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Run the futurize tool to convert to python 2 and 3 compatible code: https://pypi.org/project/future/ $ futurize -wn -u **.py
Choose between true div and floor div and remove references to old_div. Since all files now have a from __future__ import division statement, both division operators (/ and //) will behave the same in Python 2 and 3 (with the Python 3 behavior).
Add a standard set of __future__ imports so that all the code will behave consistently accross the whole library. Otherwise, new code may be caught by a missing "from __future__ import division" and would get a different behavior than in another file of Bart.
* Add dependency on "future" package. It is used to provide Python-3-like helpers and modules that will run on both Python 2 and Python 3 * Add Python 3 as supported language * Use setup.py in .travis.yml so the requirements are aligned as much as possible
Since a number of builtins like zip and map are returning iterators in Python 3 (instead of lists in Python 2), 2to3 adds calls to list() everywhere. Remove most of them as they are usually not needed.
2to3 seems to convert dict.iteritems() to iter(dict.items()) since .items() will return an iterator in Python 3 and a list in Python 2. This distinction is irrelevant in most places, so remove useless calls to iter().
In Python 3, class.method returns a function an not an unbound method as it used to in Python 2. This makes inspect.ismethod(class.method) False, so replace inspect.ismethod() with callable() builtin that will work in both cases. Also remove the use of dir() since it is meant for interactive use. Replace with inspect.getmembers(). Improve the debugging experience by using a function instead of a lambda to make it easier to find.
Since integers don't have limited size in Python 3, sys.maxint is gone. Replace its use by sys.maxsize, which is the closest approximation.
TRAPpy does not require separate trace.txt and trace.raw.txt anymore.
douglas-raillard-arm
force-pushed
the
py3k
branch
from
September 10, 2018 15:21
81115fa
to
b9a221e
Compare
That PR has been used for a few months now successfully using lisa-next (https://github.com/ARM-software/lisa/tree/next). As we seem to be the main user, I'll merge that PR in a week unless somebody screams :-) |
Please go ahead :-)
…On Fri, Feb 1, 2019, 4:55 PM Douglas Raillard ***@***.*** wrote:
That PR has been used for a few months now successfully using lisa-next (
https://github.com/ARM-software/lisa/tree/next). As we seem to be the
main user, I'll merge that PR in a week unless somebody screams :-)
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#66 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACDZbDMmEZG-U8ulZ2Yj3azwdIwB7Urqks5vJGNxgaJpZM4WenSi>
.
|
Does this have build errors still? |
Let's update setup.py to see ... |
Looks like the tests are passing, with an intermittent failure:
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Python 3 support using the past package, and its 2to3-based futurize script: https://pypi.org/project/past/
TODO: update the required version of TRAPpy once its Python 3 PR is merged
TypeError in TRAPpy are fixed by its Python 3 PR and will go away once merged