analyze-migration.py: fix read_migration_debug_json() return type
authorAlexey Kirillov <lekiravi@yandex-team.ru>
Wed, 15 Jul 2020 15:21:35 +0000 (18:21 +0300)
committerEduardo Habkost <ehabkost@redhat.com>
Fri, 18 Sep 2020 18:00:32 +0000 (14:00 -0400)
Since we use result of read_migration_debug_json() as JSON formatted string,
we must provide proper type. Before Python 3.6 json.loads() method
support only str typed input.

Signed-off-by: Alexey Kirillov <lekiravi@yandex-team.ru>
Message-Id: <20200715152135.20287-1-lekiravi@yandex-team.ru>
[ehabkost: added comment explaining why decode() is needed}
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
scripts/analyze-migration.py

index 95838cbff3f00f1ba097ee032032caa66f0f964d..d70ec7d33a680632e81b1fab618841ffbaa05a5b 100755 (executable)
@@ -97,7 +97,8 @@ class MigrationFile(object):
         # Seek back to where we were at the beginning
         self.file.seek(entrypos, 0)
 
-        return data[jsonpos:jsonpos + jsonlen]
+        # explicit decode() needed for Python 3.5 compatibility
+        return data[jsonpos:jsonpos + jsonlen].decode("utf-8")
 
     def close(self):
         self.file.close()