From caea48c879b0a5d292c74a4a3721d56350cf5537 Mon Sep 17 00:00:00 2001 Message-Id: From: Pavel Hrdina Date: Wed, 30 Jan 2019 18:28:14 +0100 Subject: [PATCH] inspection: fix check of null icon From: Pino Toscano Recently the Python binding of libguestfs was adapted to properly use bytes in APIs that return data, instead of (ab)using strings [1]. This change was done only when built for Python 3, which has this distinct bytes and strings. Because of that, now the 'icon == ""' (empty string) checks fail, using whatever inspect_get_icon() returns, including empty arrays of bytes. Hence, change the checks to use the length of the data as condition, as also the libguestfs Python API documentation says. Leave also the checks for None, in the remote case the API will return None in the future for no data. [1] https://github.com/libguestfs/libguestfs/commit/0ee02e0117527b86a31b2a88a14994ce7f15571f (cherry picked from commit bce4cc4ef837754de81e1420905159cc2fc3d773) Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1671278 Signed-off-by: Pavel Hrdina --- virtManager/inspection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virtManager/inspection.py b/virtManager/inspection.py index ea6123b8..fde48474 100644 --- a/virtManager/inspection.py +++ b/virtManager/inspection.py @@ -268,10 +268,10 @@ class vmmInspection(vmmGObject): if filesystems_mounted: # string containing PNG data icon = g.inspect_get_icon(root, favicon=0, highquality=1) - if icon == "" or icon is None: + if icon is None or len(icon) == 0: # no high quality icon, try a low quality one icon = g.inspect_get_icon(root, favicon=0, highquality=0) - if icon == "": + if icon is None or len(icon) == 0: icon = None # Inspection applications. -- 2.20.1