From e601345a38813e3f7957e1d6dfe09edb515f6382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 15 Apr 2024 14:02:13 +0200 Subject: [PATCH] Handle tracebacks as str or bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kobo 0.36.0 changed how tracebacks are handled. Instead of `bytes`, it returns a `str`. That makes pungi fail to write it into a file opened as binary. Relates: https://github.com/release-engineering/kobo/pull/246 Fixes: https://pagure.io/pungi/issue/1756 Signed-off-by: Lubomír Sedlář (cherry picked from commit 29c166ab99ba4efd0d2805e788ec3e474b4fd3c6) --- pungi/compose.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pungi/compose.py b/pungi/compose.py index e29b4019..97d7705b 100644 --- a/pungi/compose.py +++ b/pungi/compose.py @@ -718,8 +718,10 @@ class Compose(kobo.log.LoggingBase): basename += "-" + detail tb_path = self.paths.log.log_file("global", basename) self.log_error("Extended traceback in: %s", tb_path) - with open(tb_path, "wb") as f: - f.write(kobo.tback.Traceback(show_locals=show_locals).get_traceback()) + tback = kobo.tback.Traceback(show_locals=show_locals).get_traceback() + # Kobo 0.36.0 returns traceback as str, older versions return bytes + with open(tb_path, "wb" if isinstance(tback, bytes) else "w") as f: + f.write(tback) def load_old_compose_config(self): """