Bug 1121280 - History list with login names fails with non-ascii names
Summary: History list with login names fails with non-ascii names
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 20
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Honza Silhan
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2014-07-18 20:57 UTC by Göran Uddeborg
Modified: 2014-08-01 06:03 UTC (History)
6 users (show)

Fixed In Version: dnf-0.5.4-2.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2014-08-01 06:03:34 UTC
Type: Bug

Attachments (Terms of Use)

Description Göran Uddeborg 2014-07-18 20:57:30 UTC
Description of problem:
When trying to do a history list with user names rather than command lines I get a UnicodeDecodeError exception.  Some experimentation led me to the conclusion that is because of non-ascii letters in my login and full names.

Version-Release number of selected component (if applicable):

How reproducible:
Every time

Steps to Reproduce:
1. LANG=en_US.utf8 dnf --setopt=history_list_view=users history

Actual results:
ID     | Login user               | Date a | Action | Altere
Traceback (most recent call last):
  File "/usr/bin/dnf", line 36, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 206, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 82, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 132, in _main
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1163, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf/cli/commands/__init__.py", line 1530, in run
    ret = self.output.historyListCmd(extcmds)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 1668, in historyListCmd
    name = self._pwd_ui_username(old.loginuid, 24)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 1513, in _pwd_ui_username
    fullname = _safe_split_0(user.pw_gecos, ';', 2)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 1506, in _safe_split_0
    ret = text.split(*args)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)

Expected results:
A history list with my name in most of the transactions.

Additional info:
Both my login id and my full name contain non-ascii letters.  Having a non-ascii login id might be stretching the the standards a bit.  But having a non ascii full name (gecos) must be considered quite normal.

I made the following patch which seems to work around the problem:

--- output.py.orig	2014-05-28 10:27:24.000000000 +0200
+++ output.py	2014-07-18 22:49:55.000000000 +0200
@@ -1510,8 +1510,8 @@
             user = pwd.getpwuid(uid)
-            fullname = _safe_split_0(user.pw_gecos, ';', 2)
-            name = "%s <%s>" % (fullname, user.pw_name)
+            fullname = _safe_split_0(ucd(user.pw_gecos), ';', 2)
+            name = "%s <%s>" % (fullname, ucd(user.pw_name))
             if limit is not None and len(name) > limit:
                 name = "%s ... <%s>" % (_safe_split_0(fullname), user.pw_name)
                 if len(name) > limit:

If this is the right thing to do, I don't know.  Encodings in Python are a mystery to me!

Bug 1108908, on its way to be fixed, concerns another unicode issue in dnf.

Comment 1 Honza Silhan 2014-07-28 11:40:43 UTC
Fixed in the upstream.

Comment 2 Fedora Update System 2014-07-29 06:45:19 UTC
dnf-0.5.4-2.fc20 has been submitted as an update for Fedora 20.

Comment 3 Fedora Update System 2014-07-30 07:03:21 UTC
Package dnf-0.5.4-2.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.5.4-2.fc20'
as soon as you are able to.
Please go to the following url:
then log in and leave karma (feedback).

Comment 4 Fedora Update System 2014-08-01 06:03:34 UTC
dnf-0.5.4-2.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.