Skip to content

utils/systemd: stop using capture_output so Python 3.6 targets keep working#68970

Open
SAY-5 wants to merge 1 commit intosaltstack:3007.xfrom
SAY-5:fix/systemd-py36-capture-output-68778
Open

utils/systemd: stop using capture_output so Python 3.6 targets keep working#68970
SAY-5 wants to merge 1 commit intosaltstack:3007.xfrom
SAY-5:fix/systemd-py36-capture-output-68778

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 20, 2026

What does this PR do?

Replaces the two subprocess.run(..., capture_output=True) calls in salt/utils/systemd.py with the older-compatible stdout=subprocess.PIPE, stderr=subprocess.PIPE form.

capture_output was added in Python 3.7. salt-ssh still advertises 3.6 as a possible target python on older distros (see #68778), so the two call sites in _status() and _pid_to_service_systemctl would raise TypeError the moment they executed on a 3.6 remote — which is exactly what the reporter hits.

Behaviour on 3.7+ is unchanged.

What issues does this PR fix or reference?

Fixes #68778

Previous Behavior

On salt-ssh runs where the remote happens to still be on Python 3.6, any salt.utils.systemd import path that touched _status or _pid_to_service_systemctl raised:

TypeError: __init__() got an unexpected keyword argument 'capture_output'

New Behavior

Both helpers now build the pipes explicitly:

subprocess.run(
    ["systemctl", "status"],
    check=False,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
)

Merge requirements satisfied?

  • Changelog: changelog/68778.fixed.md
  • Tests — the two call sites shell out to systemctl, which isn't straightforward to unit-test without an extra fixture. Happy to add one if the maintainers prefer before merge.

Commits signed with GPG?

DCO-signed off (Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>).

…orking

salt-ssh still advertises 3.6 as a possible target python on older
distros (saltstack#68778), but salt.utils.systemd calls subprocess.run with
capture_output=True in two places. capture_output was added in
3.7, so those call sites raise TypeError under 3.6 the moment they
execute - which breaks systemd status/pid lookup on any minion
stuck on 3.6.

Replace both with the 3.6-compatible stdout=subprocess.PIPE,
stderr=subprocess.PIPE form; behaviour is identical on 3.7+.

Signed-off-by: SAY-5 <SAY-5@users.noreply.github.com>

Fixes saltstack#68778
@SAY-5 SAY-5 requested a review from a team as a code owner April 20, 2026 19:51
@frebib
Copy link
Copy Markdown
Contributor

frebib commented Apr 25, 2026

Python 3.6 is a 9 year old release than went EOL in 2021: https://endoflife.date/python

Update your python

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