Skip to content

Commit 566b6b6

Browse files
asottilegaborbernat
authored andcommitted
Read file lines as text in python2 as well (#1237)
1 parent 4cd7610 commit 566b6b6

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

docs/changelog/1234.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix sdist creation on python2.x when there is non-ascii output.

src/tox/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def popen(
104104
exit_code = process.returncode
105105
finally:
106106
if out_path is not None and out_path.exists():
107-
lines = out_path.read().split("\n")
107+
lines = out_path.read_text("UTF-8").split("\n")
108108
# first three lines are the action, cwd, and cmd - remove it
109109
output = "\n".join(lines[3:])
110110
try:

tests/unit/test_z_cmdline.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,25 @@ def test_env_VIRTUALENV_PYTHON(initproj, cmd, monkeypatch):
805805
assert "create" in result.out
806806

807807

808+
def test_setup_prints_non_ascii(initproj, cmd):
809+
initproj(
810+
"example123",
811+
filedefs={
812+
"setup.py": """\
813+
import sys
814+
getattr(sys.stdout, 'buffer', sys.stdout).write(b'\\xe2\\x98\\x83\\n')
815+
816+
import setuptools
817+
setuptools.setup(name='example123')
818+
""",
819+
"tox.ini": "",
820+
},
821+
)
822+
result = cmd("--notest")
823+
result.assert_success()
824+
assert "create" in result.out
825+
826+
808827
def test_envsitepackagesdir(cmd, initproj):
809828
initproj(
810829
"pkg512-0.0.5",

0 commit comments

Comments
 (0)