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

Update mavgen_c to python3 #1000

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jmackay2
Copy link

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.

Copy link

@bobpaul bobpaul left a 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])):
Copy link

@bobpaul bobpaul Jan 14, 2025

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
Copy link

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
Copy link

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.

@jmackay2
Copy link
Author

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.

I thought from this discussion that we might be good to move things forward to python3.

@bobpaul
Copy link

bobpaul commented Jan 22, 2025

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:

We're not going out of our way to support Python2 any more - if it breaks it breaks.

But we are also not going out of our way to kill it right now in pymavlink. That day may come - and it will be a good day!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants