From 58b538124e39a4ba6b370e776e742d01c0dc38a4 Mon Sep 17 00:00:00 2001 From: Stephen Cheng Date: Thu, 19 Dec 2024 07:57:34 +0000 Subject: [PATCH] CA-403952: Fix TapCtl._errmsg() bytes/str type issue TapCtl runs in binary mode when handling encryption key, so the stderr is of 'bytes' type, while 'str.rstrip' in _errmsg expects a 'str' object. This results in a bytes/str type mismatch issue. Signed-off-by: Stephen Cheng --- drivers/blktap2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/blktap2.py b/drivers/blktap2.py index e9887c8ed..81a98ff46 100755 --- a/drivers/blktap2.py +++ b/drivers/blktap2.py @@ -213,7 +213,7 @@ def _call(cls, args, quiet=False, input=None, text_mode=True): return cls(cmd, p) def _errmsg(self): - output = map(str.rstrip, self._p.stderr) + output = (line.rstrip() if isinstance(line, str) else line.decode('utf-8').rstrip() for line in self._p.stderr) return "; ".join(output) def _wait(self, quiet=False):