tracetool: fix usage of try_import()

try_import returns a tuple of a boolean and the requested module or attribute.
exists() functions return tracetool.try_import("tracetool.format." + name)[1]
but they should return the boolean value instead.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20250929154938.594389-2-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Paolo Bonzini 2025-09-29 17:49:23 +02:00 committed by Stefan Hajnoczi
parent 29b77c1a2d
commit 50873504dc
2 changed files with 2 additions and 2 deletions

View file

@ -94,7 +94,7 @@ def exists(name):
if name == "nop":
return True
name = name.replace("-", "_")
return tracetool.try_import("tracetool.backend." + name)[1]
return tracetool.try_import("tracetool.backend." + name)[0]
class Wrapper:

View file

@ -70,7 +70,7 @@ def exists(name):
if len(name) == 0:
return False
name = name.replace("-", "_")
return tracetool.try_import("tracetool.format." + name)[1]
return tracetool.try_import("tracetool.format." + name)[0]
def generate(events, format, backend, group):