Skip to content

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 12192: invalid start byte #31

@hereischen

Description

@hereischen

When I was calling self.serial_console.get_output(), I met UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 12192: invalid start byte.

One possible quick solution will be:
aexpect/client.py +319

@@ -314,8 +315,8 @@  def get_output(self):
         Return the STDOUT and STDERR output of the process so far.
         """
         try:
-            with open(self.output_filename, 'r') as output_file:
-                return output_file.read()
+            with open(self.output_filename, 'rb') as output_file:
+                return output_file.read().decode(errors="ignore")
         except IOError:
             return None

What is your opinion?
@clebergnu @ldoktor @chunfuwen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions