Browse Source

analyze-migration.py: fix read_migration_debug_json() return type

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>
Alexey Kirillov 5 năm trước cách đây
mục cha
commit
14f9cec713
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      scripts/analyze-migration.py

+ 2 - 1
scripts/analyze-migration.py

@@ -97,7 +97,8 @@ def read_migration_debug_json(self):
         # Seek back to where we were at the beginning
         # Seek back to where we were at the beginning
         self.file.seek(entrypos, 0)
         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):
     def close(self):
         self.file.close()
         self.file.close()