Skip to content

Conversation

@r-burns
Copy link

@r-burns r-burns commented Jan 8, 2026

The future package is not compatible with python 3.13+, so we need to replace any imports of the past module.

As far as I can tell, it's only used for basestring, which is trivial to implement using the same logic the future module uses: https://github.com/PythonCharmers/python-future/blob/2d56f83adab5a0957cfc5abbe62db1e2d1912b61/src/past/types/basestring.py#L25-L26

The `future` package is not compatible with python 3.13+, so we need to
replace any imports of the `past` module.

As far as I can tell, it's only used for basestring, which is trivial
to implement using the same logic the future module uses:
https://github.com/PythonCharmers/python-future/blob/2d56f83adab5a0957cfc5abbe62db1e2d1912b61/src/past/types/basestring.py#L25-L26
@peterbarker
Copy link
Contributor

How was this tested?

@r-burns
Copy link
Author

r-burns commented Jan 9, 2026

Nothing beyond verifying that it's importable now. Behavior should be the exact same as before, this is exactly how the basestring instance check was implemented.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please test that the new formulation actually does more than compile. Anything which crosses the mode codepath is fine.

@mode.setter
def mode(self, v):
if isinstance(v, basestring):
if isinstance(v, (bytes, str)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this technically be

Suggested change
if isinstance(v, (bytes, str)):
if isinstance(v, (unicode, str)):

?

Seriously, just:

Suggested change
if isinstance(v, (bytes, str)):
if isinstance(v, str):

... we don't need Python2 compatibility any more (pymavlink is no longer Python2-compliant so no new installs are going to work on Py2 anyway).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think unicode exists in python3, at least by default. My understanding is that it's a python2 forward-compat alias for a python3 str.

I also think code that has historically supported python2 may still be passing bytes around as strings, so that's why the past module uses (bytes, str) instead of just str. If that's not the case here for dronekit, then I agree it's simpler to just use str.

@r-burns
Copy link
Author

r-burns commented Jan 11, 2026

To elaborate a bit more on the lack of testing, I'm just packaging this for a distro so I don't really know how to use this package and test it myself. I'm just packaging it up and have noticed that it doesn't import on py313 unless I make some changes. I'd typically try to run unit tests but I don't see any here. Happy to do some actual functionality testing if you have any suggestions.

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