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

Does not handle utf8 #11

Open
anentropic opened this issue Jun 1, 2021 · 0 comments
Open

Does not handle utf8 #11

anentropic opened this issue Jun 1, 2021 · 0 comments

Comments

@anentropic
Copy link

anentropic commented Jun 1, 2021

Default encoding for JSON is UTF8 https://datatracker.ietf.org/doc/html/rfc7159#section-8.1

If you pass a file containing unicode chars to dollar_ref it will fail:

/usr/local/lib/python3.6/dist-packages/dollar_ref/__init__.py:166: in resolve_file
--
51 | file_data = read_file(path)
52 | /usr/local/lib/python3.6/dist-packages/dollar_ref/__init__.py:197: in read_file
53 | raw = file.read()
54 | /usr/lib/python3.6/encodings/ascii.py:26: in decode
55 | return codecs.ascii_decode(input, self.errors)[0]
56 | E   UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 30017: ordinal not in range(128)

I guess the call to open needs encoding="utf8" here: https://github.com/bagrat/dollar-ref/blob/master/dollar_ref/__init__.py#L196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant