Skip to content

Send flag to supress invalid UTF-8 #49

Description

@marklit

I'm running a command that outputs some metadata that has invalid UTF-8 in it. The command would finish if I was able to surpress the population of stderr. Is there a way to either call .encode('utf-8','ignore').decode('utf-8') so this exception doesn't stop everything in its tracks?

shpyx/runner.py:131, in Runner._add_stderr(self, result, data, log_output)
    128 if not data:
    129     return
--> 131 result.stderr += data.decode()
    132 result.all_output += data.decode()
    134 if _is_action_required(user=log_output, default=self._log_output):
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 637-638: invalid continuation byte

Another option might be to add a no_stderr flag to run so this section of code could be skipped over if needs be.

My workaround atm is:

result.stderr += data.decode('utf-8', 'ignore')
result.all_output += data.decode('utf-8', 'ignore')

The above isn't a great default but maybe if parameters that allowed for the above override to be passed in could at least allow those calling run to work around misbehaving commands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions