Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions spin/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import collections
import importlib
import importlib.util
import io
import os
import pathlib
import sys
Expand Down Expand Up @@ -42,6 +43,10 @@ def _detect_config_dir(path: pathlib.Path) -> pathlib.Path | None:


def main():
# Replace characters, such as emoji, that the stdout encoding cannot represent
if isinstance(sys.stdout, io.TextIOWrapper):
sys.stdout.reconfigure(errors="replace")

# Alias `spin help` to `spin --help`
if (len(sys.argv) == 2) and (sys.argv[1] == "help"):
sys.argv[1] = "--help"
Expand Down
9 changes: 9 additions & 0 deletions spin/tests/test_build_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,12 @@ def test_parallel_builds(example_pkg):
assert "build-install" in example_pkg_path
assert "parallel/build-install" in example_pkg_parallel_path
assert "parallel/build-install" not in example_pkg_path


@skip_py_lt_311 # python command does not run on older pythons
def test_unencodable_output(example_pkg):
# `spin python` prints an emoji, which ASCII cannot encode
p = spin(
"python", "--", "-c", "pass", env={**os.environ, "PYTHONIOENCODING": "ascii"}
)
assert p.returncode == 0
Loading