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

Attempt to read /raw_data/currencies.json as ascii instead of utf-8 breaks get_symbol() #109

Open
cgeorgelee opened this issue May 26, 2022 · 1 comment

Comments

@cgeorgelee
Copy link

Under certain conditions, python tries to read /raw_data/currencies.json as ascii instead of utf-8 and it cannot read the file. See the stacktrace below.

Traceback (most recent call last):
  File "/corp/views/current/project/business/display.py", line 160, in get_currency_symbol
    currency_symbol = cc.get_symbol("USD")
  File "/corp/virtualenvs/corpweb/lib/python3.8/site-packages/forex_python/converter.py", line 140, in get_symbol
    currency_dict = self._get_data(currency_code)
  File "/corp/virtualenvs/corpweb/lib/python3.8/site-packages/forex_python/converter.py", line 132, in _get_data
    currency_dict = next((item for item in self._currency_data if item["cc"] == currency_code), None)
  File "/corp/virtualenvs/corpweb/lib/python3.8/site-packages/forex_python/converter.py", line 128, in _currency_data
    self.__currency_data = json.loads(f.read())
  File "/usr/lib64/python3.8/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7400: ordinal not in range(128)
2022-05-26 00:35:53,423 ERROR display(165): get_currency_symbol: Could not decode currency_code: USD
@cgeorgelee
Copy link
Author

This is under called by Django, python 3.8, under virtualenvs on AWS Linux 2

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