Default to UTF-8 encoding in open() calls

This commit is contained in:
Anthony Sottile 2017-04-19 08:11:57 -07:00
parent 1be4e4f82e
commit e272c219fd
8 changed files with 26 additions and 18 deletions

View file

@ -3,6 +3,7 @@ from __future__ import unicode_literals
import contextlib
import errno
import functools
import io
import os.path
import shutil
import stat
@ -16,6 +17,14 @@ from pre_commit import five
from pre_commit import parse_shebang
def open(*args, **kwargs):
"""Some strange interaction with python2, osx, and vscode makes default
encoding detection go wrong. See #519
"""
kwargs.setdefault('encoding', 'UTF-8')
return io.open(*args, **kwargs)
@contextlib.contextmanager
def cwd(path):
original_cwd = os.getcwd()