Skip to content

UnicodeDecodeError when command output is non-utf-8 #2969

@masenf

Description

@masenf

Issue

% tox
py: commands[0]> /usr/bin/env bash -c 'printf "\xed"'
py: internal error
Traceback (most recent call last):
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/session/cmd/run/single.py", line 46, in _evaluate
    code, outcomes = run_commands(tox_env, no_test)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/session/cmd/run/single.py", line 83, in run_commands
    status_main = run_command_set(tox_env, "commands", chdir, ignore_errors, outcomes)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/session/cmd/run/single.py", line 98, in run_command_set
    current_outcome = tox_env.execute(
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/tox_env/api.py", line 392, in execute
    pass  # pragma: no cover
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/tox_env/api.py", line 438, in execute_async
    self._execute_statuses.pop(execute_id)
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/tox_env/api.py", line 489, in _execute_call
    yield execute_status
  File "/usr/lib/python3.8/contextlib.py", line 120, in __exit__
    next(self.gen)
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/execute/api.py", line 136, in call
    out_sync.text,
  File "/home/mfurer/.pytools/lib/python3.8/site-packages/tox/execute/stream.py", line 103, in text
    return self._content.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 0: unexpected end of data

Environment

Provide at least:

  • OS: ubuntu 22.04
  • pip list of the host Python where tox is installed:
cachetools==5.3.0
chardet==5.1.0
colorama==0.4.6
distlib==0.3.6
filelock==3.9.1
packaging==23.0
platformdirs==3.1.1
pluggy==1.0.0
pyproject_api==1.5.1
tomli==2.0.1
tox==4.4.7
virtualenv==20.21.0

Minimal example

If possible, provide a minimal reproducer for the issue:

[testenv]
allowlist_externals = /usr/bin/env
commands =
    /usr/bin/env bash -c 'printf "\xed"'

Metadata

Metadata

Assignees

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