UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 54:
Peter Otten
__peter__ at web.de
Sun Apr 24 18:14:32 EDT 2016
arthur sherman wrote:
> m using a python web applic (adagios, a nagios configuration tool).
> when attempting a certain operation on the client side browser i get the
> above error. the client side is ubunti 14.04. servers side is debian 8.
> browser is ff or chrome. both show:
> echo $LANG
> en_US.UTF-8
>
> before i dive into the code, r there any OS level things to try?
> here's the full error traceback:
>
> Traceback (most recent call last):
> File "/opt/adagios/adagios/views.py", line 43, in wrapper
> result = view_func(request, *args, **kwargs)
> File "/opt/adagios/adagios/objectbrowser/views.py", line 191, in
> edit_object c['form'] = PynagForm(pynag_object=my_object,
> initial=my_object._original_attributes) File
> "/opt/adagios/adagios/objectbrowser/forms.py", line 312, in __init__
> self.fields[field_name] = self.get_pynagField(field_name,
> css_tag="inherited") File "/opt/adagios/adagios/objectbrowser/forms.py",
> line 418, in get_pynagField _('%(inherited_value)s (inherited from
> template)') % {'inherited_value': smart_str(inherited_value)}
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 54:
> ordinal not in range(128)
Probably one of
_(...)
or
smart_str(...)
returns unicode and the other returns a non-ascii bytestring:
>>> u"%s" % "\xe2"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0:
ordinal not in range(128)
>>> "\xe2 %s" % u"foo"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0:
ordinal not in range(128)
> before i dive into the code, r there any OS level things to try?
Probably not. If you entered non-ascii text into a form, and can limit
yourself to ascii-only then that might be a workaround...
More information about the Python-list
mailing list