Skip to content

Python3.7 compatibility in testsuite, plus new CI workflow to test it - #1167

Open
elboulangero wants to merge 5 commits into
RsyncProject:masterfrom
elboulangero:python3.7
Open

elboulangero wants to merge 5 commits into
RsyncProject:masterfrom
elboulangero:python3.7

Conversation

@elboulangero

Copy link
Copy Markdown
Contributor

Description

This commits makes the test suite compatible with Python 3.7. For a use-case: I'm working on backporting rsync 3.5 to Debian buster, which comes with Python 3.7. While Debian buster is archived (read-only), it is still supported via Freexian ELTS offering, cf. https://wiki.debian.org/LTS/Extended?pow_referer=https%3A%2F%2Fwww.google.com%2F. ELTS is a commercial offering, so only avail to customers.

Still, if you think that compat with Python 3.7 is worth keeping for others, then here's a pull request!

Also note that the changes are minor, so basically Python 3.7 is almost supported (My guess is that it was supported but then was broken due to lack of CI).

Consequently, this pull request also adds a CI workflow to make sure Python 3.7 support is tested and keeps working.

Implementation

There are mainly two things missing in Python 3.7:

  • shlex.join
  • Argument missing_ok for function Path.unlink.

I solved both by defining wrappers, and replacing direct calls by calls to the wrapper.

Maybe the fix for missing shlex.join could be made a bit more elegant. For example, we can define shlex.join if missing in a file compat.py (or even straight in rsyncfns.py), so that it can then be used transparently. But it also means that all script that use shlex.join need to import compat.py (otherwise it will fail on Python 3.7), which is maybe not obvious.

I suppose the same approach can be taken for Path.unlink, the function is just a few lines long, so I suppose we can re-implement it in case of Python 3.7.

Any preference ? I think that second approach would work better, so I can rework, no problem.

elboulangero and others added 4 commits November 12, 2026 10:35
shlex.join was added in Python 3.8

This commit adds a wrapper 'join_and_quote', which just invokes
shlex.join if it exists, and otherwise basically implements it (the
implementation is just a one-line in the Python stdlib, so it's easy to
reproduce it here).

Then the commit replaces all calls to shlex.join with calls to
join_and_quote so that it works with Python 3.7
This was introduced in Python 3.8

This commit adds a wrapper unlink_missing_ok, which just calls
Path.unlink(missing_ok=True) for Python 3.8 or above, and otherwise
falls back to the try/except method.

Then this commit also replaces all occurences to unlink(missing_ok=True)
with calls to unlink_missing_ok, so that it works with Python 3.7.
@elboulangero

elboulangero commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

One test fails (full log at https://github.com/RsyncProject/rsync/actions/runs/43154963062/job/130972649691):

----- password-file-first-line log follows
Traceback (most recent call last):
  File "/__w/rsync/rsync/testsuite/password-file-first-line_test.py", line 59, in <module>
    'wrong-fallback' if succeeds else PASSWORD.decode()})
  File "/usr/lib/python3.7/subprocess.py", line 462, in run
    raise ValueError('stdin and input arguments may not both be used.')
ValueError: stdin and input arguments may not both be used.
----- password-file-first-line log ends

I checked but can't figure out how to fix it, the call to subprocess.run is too smart for me, and I suppose it's also too smart for Python 3.7. This test pass for other workflows, so I suppose the call to subprocess.run needs to be reworked / simplified a bit to fix it for Python 3.7

@elboulangero

Copy link
Copy Markdown
Contributor Author

I checked but can't figure out how to fix it, the call to subprocess.run is too smart for me, and I suppose it's also too smart for Python 3.7. This test pass for other workflows, so I suppose the call to subprocess.run needs to be reworked / simplified a bit to fix it for Python 3.7

I fixed it with the last commit of this pull request.

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.

1 participant