-
Notifications
You must be signed in to change notification settings - Fork 609
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
Update mavgen_c to python3 #1000
base: master
Are you sure you want to change the base?
Conversation
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'm not a project maintainer, but from reading other comments on github, I understand pymavlink is not yet ready to intentionally remove python2 support.
python-future
at least partially requires (for running the tests for sure) lib2to3 which was removed in python13. Removing pymavlink's dependence on the future
module seems reasonable and certainly for this file can be done without breaking python2 compatibility.
@@ -675,7 +670,7 @@ def generate_one(basename, xml): | |||
# form message name array | |||
xml.message_name_array = '' | |||
# sort by names | |||
for msgid, name in sorted(iteritems(xml.message_names), key=lambda k_v: (k_v[1], k_v[0])): | |||
for msgid, name in sorted(xml.message_names.items(), key=lambda k_v: (k_v[1], k_v[0])): |
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.
This runs the same on Python 2 as Python 3. iteritems()
from future is for performance, not correctness.
from __future__ import print_function | ||
from future.utils import iteritems | ||
|
||
from builtins import range |
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.
leaving the from __future__
and from builtins
lines has no real impact on python3 but maintains compatibility with python2.
@@ -1,15 +1,10 @@ | |||
#!/usr/bin/env python | |||
#!/usr/bin/env python3 |
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.
leave this as python for now.
I thought from this discussion that we might be good to move things forward to python3. |
I had read that discussion, too, and it wasn't clear to me they had made a decision. Peter's comment a few months ago in #976 look clear to me that they still don't want us to intentionally remove Python2 support, just don't jump through hoops to maintain support:
One of the things to keep in mind is that a lot of use of mavlink is on embedded devices in the air. While it's easy to get python3 support on our computers, getting python3 on an out of production intel edison or some other product that never had an official BSP for any embedded linux new enough to include python3 could be challenging for some users. (That's a situation I was in about 3 years ago). |
Most of the code was already compatible with python3 except for the small change for iteritems. The builtins and print_function were put in to make it python3 compatible, so those are no longer necessary.