mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Use open built-in to open files
* This makes Python 3 not raise UnicodeDecodeError when reading files
This commit is contained in:
parent
9573c13884
commit
51f8cc8ff0
6 changed files with 9 additions and 14 deletions
|
|
@ -3,7 +3,6 @@ from __future__ import print_function
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import sys
|
||||
import xml.sax
|
||||
|
||||
|
|
@ -16,7 +15,7 @@ def check_xml(argv=None):
|
|||
retval = 0
|
||||
for filename in args.filenames:
|
||||
try:
|
||||
with io.open(filename, 'rb') as xml_file:
|
||||
with open(filename, 'rb') as xml_file:
|
||||
xml.sax.parse(xml_file, xml.sax.ContentHandler())
|
||||
except xml.sax.SAXException as exc:
|
||||
print('{0}: Failed to xml parse ({1})'.format(filename, exc))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue