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,13 +3,14 @@ from __future__ import unicode_literals
import collections
import contextlib
import io
import os.path
import re
import sys
import six
from pre_commit import util
class ValidationError(ValueError):
def __init__(self, error_msg, ctx=None):
@ -266,7 +267,7 @@ def load_from_filename(filename, schema, load_strategy, exc_tp):
if not os.path.exists(filename):
raise ValidationError('{} does not exist'.format(filename))
with io.open(filename) as f:
with util.open(filename) as f:
contents = f.read()
with validate_context('File {}'.format(filename)):