diff mbox series

oeqa: fix OETestCalledProcessError for check_output method

Message ID 20250731193506.13665-1-peter.marko@siemens.com
State New
Headers show
Series oeqa: fix OETestCalledProcessError for check_output method | expand

Commit Message

Marko, Peter July 31, 2025, 7:35 p.m. UTC
From: Peter Marko <peter.marko@siemens.com>

Per documentation, subprocess.CalledProcessError exception has stderr
filled out only for run method, it's None for check_output method.
So serialize it only if it's not None.

Avoids:
  File "<poky-dir>/meta/lib/oeqa/utils/subprocesstweak.py", line 15, in __str__
    s = s + "\nStandard Error: " + strify(self.stderr)
        ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str

Signed-off-by: Peter Marko <peter.marko@siemens.com>
---
 meta/lib/oeqa/utils/subprocesstweak.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/lib/oeqa/utils/subprocesstweak.py b/meta/lib/oeqa/utils/subprocesstweak.py
index 1774513023..046667faa9 100644
--- a/meta/lib/oeqa/utils/subprocesstweak.py
+++ b/meta/lib/oeqa/utils/subprocesstweak.py
@@ -12,7 +12,9 @@  class OETestCalledProcessError(subprocess.CalledProcessError):
 
         s = super().__str__()
         s = s + "\nStandard Output: " + strify(self.output)
-        s = s + "\nStandard Error: " + strify(self.stderr)
+        # stderr is not available for check_output method
+        if self.stderr != None:
+            s = s + "\nStandard Error: " + strify(self.stderr)
         return s
 
 def errors_have_output():