From 9da6764eb86adc9e43a113a901a44d1780fe669a Mon Sep 17 00:00:00 2001 From: Niklas Rousset Date: Mon, 26 Aug 2024 22:28:22 +0200 Subject: [PATCH] Convert stdin string to bytes regardless of stdin_raw_newlines --- changelog/62501.fixed.md | 1 + salt/utils/timed_subprocess.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 changelog/62501.fixed.md diff --git a/changelog/62501.fixed.md b/changelog/62501.fixed.md new file mode 100644 index 00000000000..5b9b0460322 --- /dev/null +++ b/changelog/62501.fixed.md @@ -0,0 +1 @@ +Convert stdin string to bytes regardless of stdin_raw_newlines diff --git a/salt/utils/timed_subprocess.py b/salt/utils/timed_subprocess.py index 627d3f712ed..c41d1a7377b 100644 --- a/salt/utils/timed_subprocess.py +++ b/salt/utils/timed_subprocess.py @@ -33,9 +33,8 @@ class TimedProc: if not self.stdin_raw_newlines: # Translate a newline submitted as '\n' on the CLI to an actual # newline character. - self.stdin = salt.utils.stringutils.to_bytes( - self.stdin.replace("\\n", "\n") - ) + self.stdin = self.stdin.replace("\\n", "\n") + self.stdin = salt.utils.stringutils.to_bytes(self.stdin) kwargs["stdin"] = subprocess.PIPE if not self.with_communicate: