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

RANGER-5147: Modernize some Python scripts now that Python 3 is a requirement #533

Merged
merged 7 commits into from
Feb 21, 2025

Conversation

ksobolew
Copy link
Contributor

What changes were proposed in this pull request?

Now that Python 3 is a requirement, we can remove some compatibility with Python 2, replace obsolete function calls and fix escape sequences that Python 3 treats as invalid.

This is not a comprehensive review of all Python scripts! Just the things that we noticed while having to adjust to a version of Python that's even newer than the 3.8 given as the minimum required version.

How was this patch tested?

Some of those changes are running in production on our deployments.

We no longer need to keep compatibility with Python 2.
We no longer need to keep compatibility with Python 2.
This method was added in Python 3.2 as a replacement for `readfp`, which
was removed in a later version of Python. Ranger requires at least
Python 3.8, so it's safe to use the replacement.
We no longer need to keep compatibility with Python 2.
We no longer need to keep compatibility with Python 2.
The backtick does not have to be escaped in string constants.
The Python interpreter, when it sees e.g. "%s\jisql", issues a warning
that `\j` is not a valid escape, then converts it to `\\j` anyway, so in
the end this ends up as a valid Windows path after all. But this *is*
technically a syntax error and I heard over the grapevine that it will
turn into a hard error some time in the future.

Also, some users really don't like warnings in their logs.
@mneethiraj mneethiraj merged commit 7d553f1 into apache:master Feb 21, 2025
3 checks passed
mneethiraj pushed a commit that referenced this pull request Feb 21, 2025
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