#317 Unicode errors during libtaskotron run when default encoding is different
Closed: Fixed Opened by mkrizek.

With D733, there are unicode errors in my terminal:

[libtaskotron:os_utils.py:42] 2016-02-09 09:51:12 DEBUG    Sudo access is not available. Received exit code 1 and output:
sudo: a password is required
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 58: ordinal not in range(128)
Logged from file os_utils.py, line 42
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 58: ordinal not in range(128)
Logged from file os_utils.py, line 42
[libtaskotron:rpm_utils.py:231] 2016-02-09 09:51:12 DEBUG   Deciding whether DNF cache is available. Running: dnf --cacheonly repolist
[libtaskotron:rpm_utils.py:239] 2016-02-09 09:51:12 DEBUG    DNF cache is available.
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 60: ordinal not in range(128)
Logged from file rpm_utils.py, line 239
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 60: ordinal not in range(128)
Logged from file rpm_utils.py, line 239
[libtaskotron:os_utils.py:36] 2016-02-09 09:51:12 DEBUG   Deciding whether we have a password-less sudo access. Running: sudo --validate --non-interactive
[libtaskotron:os_utils.py:42] 2016-02-09 09:51:12 DEBUG    Sudo access is not available. Received exit code 1 and output:
sudo: a password is required
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 58: ordinal not in range(128)
Logged from file os_utils.py, line 42
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 58: ordinal not in range(128)
Logged from file os_utils.py, line 42
[libtaskotron:rpm_utils.py:198] 2016-02-09 09:51:12 INFO    Checking installed state of 1 packages...
[libtaskotron:rpm_utils.py:199] 2016-02-09 09:51:12 DEBUG   Running: dnf --cacheonly --assumeno --disableplugin=noroot install rpmlint
[libtaskotron:rpm_utils.py:208] 2016-02-09 09:51:13 DEBUG    All specified packages are installed
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 60: ordinal not in range(128)
Logged from file rpm_utils.py, line 208
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 882, in emit
    stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 60: ordinal not in range(128)
Logged from file rpm_utils.py, line 208

It's because of this:

>>> import sys
>>> sys.getdefaultencoding()
'ascii'

I believe I am not only one who will hit this issue.

See:
http://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte

Propose a fix.


This ticket had assigned some Differential requests:
D741
D733

Fixed in D741.

Metadata