Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add safety wrapper around sys.stdout assignment #724

Merged
merged 4 commits into from
Jan 5, 2018
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 changelog/723.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fixed an issue where invocation of Tox from the Python package, where
invocation errors (failed actions) occur results in a change in the
sys.stdout stream encoding in Python 3.x.
New behaviour is that sys.stdout is reset back to its original encoding
after invocation errors - by @tonybaloney
8 changes: 5 additions & 3 deletions tox/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,11 @@ def run_install_command(self, packages, action, options=()):

old_stdout = sys.stdout
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
self._pcall(argv, cwd=self.envconfig.config.toxinidir, action=action,
redirect=self.session.report.verbosity < 2)
sys.stdout = old_stdout
try:
self._pcall(argv, cwd=self.envconfig.config.toxinidir,
action=action, redirect=self.session.report.verbosity < 2)
finally:
sys.stdout = old_stdout

def _install(self, deps, extraopts=None, action=None):
if not deps:
Expand Down