Skip to content
This repository was archived by the owner on Dec 10, 2018. It is now read-only.

Fix ascii error when thrift file has chinese chars. #314

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion thriftpy/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def parse(path, module_name=None, include_dirs=None, include_dir=None,
with open(urlparse(path).netloc + urlparse(path).path) as fh:
data = fh.read()
elif url_scheme == '':
with open(path) as fh:
with open(path, encoding='utf-8') as fh:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

py2.7 has no keyword argument encoding. So maybe it's better to read the file in binary mode and decode it to utf-8.

data = fh.read()
elif url_scheme in ('http', 'https'):
data = urlopen(path).read()
Expand Down