From eee38e73c3d9479cc2f907a9fd8d6fafbc349038 Mon Sep 17 00:00:00 2001 From: Tal Berlowitz Date: Wed, 6 Jul 2022 18:08:13 +0300 Subject: [PATCH] Fix the return value of utils._execute_subprocess If the output of the subprocess is empty, then an empty object is returned (b''), and not decoded into an empty object. This may result in errors such as: info[109734]: executing /bin/ip -6 addr show eth0 networking[109734]: error: eth0: cannot use a string pattern on a bytes-like object error[109734]: eth0: cannot use a string pattern on a bytes-like object --- ifupdown2/ifupdown/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ifupdown2/ifupdown/utils.py b/ifupdown2/ifupdown/utils.py index 2f7dc78..a474ed8 100644 --- a/ifupdown2/ifupdown/utils.py +++ b/ifupdown2/ifupdown/utils.py @@ -386,7 +386,7 @@ class utils(): finally: utils.disable_subprocess_signal_forwarding(signal.SIGINT) - cmd_output_string = cmd_output.decode() if cmd_output else cmd_output + cmd_output_string = cmd_output.decode() if cmd_output is not None else cmd_output if cmd_returncode != 0: raise Exception(cls._format_error(cmd,