# 'ascii' codec can't decode in 3.2.2

**URL:** <https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947>\
**Category:** Administrators\
**Created:** [February 6, 2023, 11:04pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947 "2023-02-06T23:04:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadlec](https://talk.getindico.io/letter_avatar_proxy/v4/letter/k/9de0a6/32.png) [@kadlec](https://talk.getindico.io/u/kadlec)\
**Post date:** [February 6, 2023, 11:04pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947/1 "2023-02-06T23:04:21Z")

</div>

Hi,

After upgrading Indico from 2.3 to 3.2.2 without any problem, Indico sent an error message with the subject: Unexpected Exception occurred at indico1.kfki.hu: ‘ascii’ codec can’t decode byte 0xc2 in position 14853: ordinal not in range(128)  
How could we fix the issue?

Thanks in advance,  
Jozsef

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [February 6, 2023, 11:12pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947/2 "2023-02-06T23:12:12Z")

</div>

You need to provide full traceback… if it was an error email, the email’s body contains the interesting parts.

---

<div class="post-metadata">

**Author:** ![kadlec](https://talk.getindico.io/letter_avatar_proxy/v4/letter/k/9de0a6/32.png) [@kadlec](https://talk.getindico.io/u/kadlec)\
**Post date:** [February 6, 2023, 11:15pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947/3 "2023-02-06T23:15:11Z")

</div>

Here follows the full email, sorry for the broken long lines. I don’t see a way to attach file:

```plaintext
2023-02-06 23:37:40,604 b8b4e8e8a65b49c0 indico.flask - ERROR errors.py:110 -- 'ascii'
codec can't decode byte 0xc2 in position 14853: ordinal not in range(128)

Traceback (most recent call last):
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/app.py", line 1820, in
full_dispatch_request
    rv = self.dispatch_request()
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/app.py", line 1796, in
dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/blueprint.py",
line 85, in i18n_locale_react
    return _get_i18n_locale(locale_name, react=True)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/blueprint.py",
line 107, in _get_i18n_locale
    i18n_data = generate_i18n_file(locale_name, react=react)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/vars_js.py",
line 47, in generate_i18n_file
    i18n_data = get_locale_data(root_path, locale_name, 'indico', react=react)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/vars_js.py",
line 29, in get_locale_data
    rv = json.load(f)
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/json/ __init__.py", line
251, in load
    return app.json.load(fp, **kwargs)
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/json/provider.py", line
74, in load
    return self.loads(fp.read(), **kwargs)
  File "/services/indico/.pyenv/versions/3.9.16/lib/python3.9/encodings/ascii.py", line 26,
in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 14853: ordinal not in
range(128)

{'data': {'get': {},
          'headers': {'Accept': '*/*',
                      'Accept-Encoding': 'gzip, deflate',
                      'Accept-Language': 'en-US,en;q=0.9',
                      'Connection': 'keep-alive',
                      'Host': 'indico.wigner.hu',
                      'Referer':
'https://indico.wigner.hu/event/4/timetable/?view=standard',
                      'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X '
                                    '10_15_5) AppleWebKit/605.1.15 (KHTML, '
                                    'like Gecko) Version/13.1.1 '
                                    'Safari/605.1.15 (Applebot/0.1; '
                                    '+http://www.apple.com/go/applebot)'},
          'json': None,
          'post': {},
          'url': {'locale_name': 'en_GB'}},
'endpoint': 'assets.i18n_locale_react',
 'id': 'b8b4e8e8a65b49c0',
 'ip': '17.22.245.190',
 'method': 'GET',
 'referrer': 'https://indico.wigner.hu/event/4/timetable/?view=standard',
 'rh': None,
 'time': '2023-02-06T23:37:40.673171',
 'url': 'https://indico.wigner.hu/assets/i18n/en_GB-react.js',
 'user': None,
 'user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) '
               'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 '
               'Safari/605.1.15 (Applebot/0.1; '
               '+http://www.apple.com/go/applebot)'}

```

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [February 6, 2023, 11:23pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947/4 "2023-02-06T23:23:47Z")

</div>

For some reason your Python uses the `ascii` codec by default instead of `utf-8` which is supposed to be the standard in Python 3.

Fixing this will also make the error go away. Is your LC\_TYPE not set to an UTF8 locale by any chance?

Tip: For testing simply go to [https://indico.wigner.hu/assets/i18n/en\_GB-react.js](https://indico.wigner.hu/assets/i18n/en_GB-react.js) directly and see if it works or not.

PS: I added backtick fences around your pasted content, that way it’s properly rendered in monospace (Discourse uses Markdown for formatting).

---

<div class="post-metadata">

**Author:** ![kadlec](https://talk.getindico.io/letter_avatar_proxy/v4/letter/k/9de0a6/32.png) [@kadlec](https://talk.getindico.io/u/kadlec)\
**Post date:** [February 6, 2023, 11:34pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947/5 "2023-02-06T23:34:44Z")

</div>

DEFAULT\_LOCALE was left to the default en\_GB in indico.conf. Now I set it to en\_US.UTF-8 and restarted uwsgi. Going to the [https://indico.wigner.hu/assets/i18n/en\_GB-react.js](https://indico.wigner.hu/assets/i18n/en_GB-react.js) URL it seems it loads OK and no error email sent.

Thanks indeed! You are doing a great support!  
Jozsef

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://talk.getindico.io/user_avatar/talk.getindico.io/thiefmaster/32/509_2.png) [@ThiefMaster](https://talk.getindico.io/u/ThiefMaster)\
**Post date:** [February 6, 2023, 11:35pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947/6 "2023-02-06T23:35:55Z")

</div>

The indico.conf locale should NOT matter there and in fact `en_US.UTF-8` there is not a valid locale as far as Indico is concerned I’m very surprised that this fixed something - unless it was just the uwsgi restart that fixed whatever problem you had before…

In any case, it’d be better to change the system locale (global `LC_CTYPE` value).

Also, could you paste the current output when running `locale` on a terminal to see what’s currently configured?

---

<div class="post-metadata">

**Author:** ![kadlec](https://talk.getindico.io/letter_avatar_proxy/v4/letter/k/9de0a6/32.png) [@kadlec](https://talk.getindico.io/u/kadlec)\
**Post date:** [February 6, 2023, 11:53pm UTC](https://talk.getindico.io/t/ascii-codec-cant-decode-in-3-2-2/2947/7 "2023-02-06T23:53:25Z")

</div>

The system locale was set to “C”. I modified it to en\_US.UTF-8, configured DEFAULT\_LOCALE back to en\_GB in indico.conf and restarted uwsgi.

All seems to be good 🙂
