Skip to content
Snippets Groups Projects
  • Laurent Vivier's avatar
    2c92be50
    analyze-migration.py: fix extract contents ('-x') errors · 2c92be50
    Laurent Vivier authored
    
    When we try to use 'analyze-migration.py -x' with python3,
    we have the following errors:
    
      Traceback (most recent call last):
        File "scripts/analyze-migration.py", line 593, in <module>
          f.write(jsonenc.encode(dump.vmsd_desc))
      TypeError: a bytes-like object is required, not 'str'
    
      Traceback (most recent call last):
        File "scripts/analyze-migration.py", line 601, in <module>
          f.write(jsonenc.encode(dict))
      TypeError: a bytes-like object is required, not 'str'
    
    This happens because the file 'f' is open in binary mode while
    jsonenc.encode() returns a string.
    
    The results are human-readable files, 'desc.json' and 'state.json',
    so there is no reason to use the binary mode.
    
    Signed-off-by: default avatarLaurent Vivier <lvivier@redhat.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Message-Id: <20211015131645.501281-3-lvivier@redhat.com>
    Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>
    2c92be50
    History
    analyze-migration.py: fix extract contents ('-x') errors
    Laurent Vivier authored
    
    When we try to use 'analyze-migration.py -x' with python3,
    we have the following errors:
    
      Traceback (most recent call last):
        File "scripts/analyze-migration.py", line 593, in <module>
          f.write(jsonenc.encode(dump.vmsd_desc))
      TypeError: a bytes-like object is required, not 'str'
    
      Traceback (most recent call last):
        File "scripts/analyze-migration.py", line 601, in <module>
          f.write(jsonenc.encode(dict))
      TypeError: a bytes-like object is required, not 'str'
    
    This happens because the file 'f' is open in binary mode while
    jsonenc.encode() returns a string.
    
    The results are human-readable files, 'desc.json' and 'state.json',
    so there is no reason to use the binary mode.
    
    Signed-off-by: default avatarLaurent Vivier <lvivier@redhat.com>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
    Message-Id: <20211015131645.501281-3-lvivier@redhat.com>
    Signed-off-by: default avatarLaurent Vivier <laurent@vivier.eu>