-
Notifications
You must be signed in to change notification settings - Fork 115
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
Stage 2 of Porting Python 2 Code to Python 3 #40
Conversation
Add dependency on the future package, required for stage 2 of futurize.
Stage 2 of futurize in `rflib/*.py`. The goal of stage 2 is to make further mostly safe changes to the Python 2 code to use Python 3-style code that still runs on Python 2 with the help of the appropriate builtins and utilities in `future`.
Automatically run stage 2 of futurize (except for vstruct/*) on all Python files. Futurize did not rewrite all divisions, and I think we we need to fix the Note: this PR is still work in progress! |
The Python 2 integer types int and long have been unified in Python 3. So there is now only one type, int.
Import cPickle on Python 2 and pickle on Python 3.
you waiting on me? or am i waiting on you? :) bump if i fall off the face of the planet. |
@atlas0fd00m, you are waiting on my! I am currently very busy, hope to get some work done on the PR next weekend. |
Update chr() to bytes([]) after Futurize stage 2 caused errors. For more information see: https://python-future.org/compatible_idioms.html#chr
@atlas0fd00m Finally got some spare time to work on this PR, so it's now ready to be merged. Unfortunately I don't have much time to work on this in the coming weeks... |
aa.sort() | ||
return aa | ||
|
||
def minaddr(self): | ||
'''Get minimal address of HEX content. | ||
@return minimal address or None if no data | ||
''' | ||
aa = self._buf.keys() | ||
aa = list(self._buf.keys()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i notice a lot of this. is there a problem accessing the list returned from keys() in Py3? or is this a stylistic thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Python 3 the dict.keys()
will return a dict_keys
object instead of a list, e.g.:
>>> my_dict = {'first': 1, 'second': 2}
>>> my_dict.keys()
dict_keys(['first', 'second'])
>>> list(my_dict.keys())
['first', 'second']
For more information see: PEP 3106 -- Revamping dict.keys(), .values() and .items().
@roaldnefs where do we stand on this? How can I help? Also, do you have a recommended Python ENV setup so I'm working from the same place as you, @atlas0fd00m, and others |
@cutaway, the description of this PR is up to date with my latest changes. You may also take a look at #15, this issue contains some extra information about achieving Python 3 compatibility. I just use virtualenv to create a virtual environment for both Python 2 and 3. Tip: python-future.org is a greate resource! |
@roaldnefs, @cutaway how are we doing on the next phase of py3 migration? :) |
This PR is part of porting the Python 2 code to Python 3 without losing compatibility for Python 2.7 according to https://python-future.org/futurize.html.
Note: this PR is still work in progress!
Description:
Stage 1 will apply fixes to modernize the Python 2 code without changing the effect of the code. The goal of this stage is to create most of the diff for the entire porting process, but without introducing any bugs.
Stage 2 will add a dependency on the
future
package. The goal for stage 2 is to make further mostly safe changes to the Python 2 code to use Python 3 style code that still runs on Python 2 with the help of the appropriate builtins and utilities infuture
.In stage 3 we will be separating text from bytes manually by prefixing all the string literals with either
b
oru
accordingly. To ensure that these type behave similarly on Python 2 as on Python 3, we will wrap byte-strings or text in thebytes
andstr
types fromfuture
.After running
futurize
, we start by testing compatibility on Python 3 and making further code changes until it's fully compatible with Python 3. The next step is to make manual tweaks to the code to re-enable Python 2 compatibility.Action Items:
futurize
(except forvstruct/*
)futurize
.futurize
(except forvstruct/*
)futurize
invstruct/*
futurize
changes invstruct/*
into masterAdditional Information:
This PR is part of fixing #15.