diff mbox series

[PULL,2/2] analyze-migration.py: fix read_migration_debug_json() return type

Message ID 20200918180451.1121055-3-ehabkost@redhat.com
State New
Headers show
Series Python queue, 2020-09-18 | expand

Commit Message

Eduardo Habkost Sept. 18, 2020, 6:04 p.m. UTC
From: Alexey Kirillov <lekiravi@yandex-team.ru>

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py
index 95838cbff3..d70ec7d33a 100755
--- a/scripts/analyze-migration.py
+++ b/scripts/analyze-migration.py
@@ -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()