Bug 1123886

Summary: [abrt] dnf: i18n.py:138:_exact_width_char:TypeError: must be unicode, not str
Product: [Fedora] Fedora Reporter: Marcela Mašláňová <mmaslano>
Component: dnf-plugins-coreAssignee: Miroslav Suchý <msuchy>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: akozumpl, asamalik, bblaskov, hhorak, ignatenko, jsilhan, lnie, mizdebsk, msuchy, packaging-team-maint, pnemade, rbean, rholy, sirdeiu, tim.lauridsen, ttomecek
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
URL: https://retrace.fedoraproject.org/faf/reports/bthash/56cc0d0643be8386989df18098452afa0e5c2136
Whiteboard: abrt_hash:3f34490b19c15f2d9cbd2d3dbbfb0bf73dc29eb5
Fixed In Version: dnf-plugins-core-0.1.1-4.fc20 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-23 04:29:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1128135    
Bug Blocks:    
Attachments:
Description Flags
File: backtrace
none
File: environ none

Description Marcela Mašláňová 2014-07-28 14:37:51 UTC
Description of problem:
I was using dnf-plugins-core, but I'm surprised that abrt catch it.

dnf copr list bkabrda
=========================================================================================================== List of bkabrda coprs ===========================================================================================================
Traceback (most recent call last):
  File "/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 200, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 83, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 133, in _main
    cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1171, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/copr.py", line 132, in run
    msg = self.base.output.fmtKeyValFill(msg, desc)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 704, in fmtKeyValFill
    keylen = exact_width(key)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in exact_width
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in <genexpr>
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 138, in _exact_width_char
    return 2 if unicodedata.east_asian_width(uchar) in ('W', 'F', 'A') else 1
TypeError: must be unicode, not str

Version-Release number of selected component:
dnf-0.5.4-1.fc20

Additional info:
reporter:       libreport-2.2.3
cmdline:        /usr/bin/python -OO /bin/dnf copr list bkabrda
dso_list:       dnf-plugins-core-0.1.1-2.fc20.noarch
executable:     /bin/dnf
kernel:         3.14.7-200.fc20.x86_64
runlevel:       N 5
type:           Python
uid:            0

Truncated backtrace:
i18n.py:138:_exact_width_char:TypeError: must be unicode, not str

Traceback (most recent call last):
  File "/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 200, in user_main
    errcode = main(args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 83, in main
    return _main(base, args)
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 133, in _main
    cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1171, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/copr.py", line 132, in run
    msg = self.base.output.fmtKeyValFill(msg, desc)
  File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 704, in fmtKeyValFill
    keylen = exact_width(key)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in exact_width
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in <genexpr>
    return sum(_exact_width_char(c) for c in msg)
  File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 138, in _exact_width_char
    return 2 if unicodedata.east_asian_width(uchar) in ('W', 'F', 'A') else 1
TypeError: must be unicode, not str

Local variables in innermost frame:
uchar: 'b'

Comment 1 Marcela Mašláňová 2014-07-28 14:37:54 UTC
Created attachment 921773 [details]
File: backtrace

Comment 2 Marcela Mašláňová 2014-07-28 14:37:55 UTC
Created attachment 921774 [details]
File: environ

Comment 3 Ales Kozumplik 2014-07-28 14:52:05 UTC
Moving to the COPR guys. Miroslav, plugins are not supposed to use output.fmtKeyValFill(), it is not in the API.

Also CCing jsilhan, FYI.

Comment 4 Miroslav Suchý 2014-08-08 09:54:01 UTC
*** Bug 1128096 has been marked as a duplicate of this bug. ***

Comment 5 Igor Gnatenko 2014-08-08 09:59:25 UTC
(In reply to Ales Kozumplik from comment #3)
> Moving to the COPR guys. Miroslav, plugins are not supposed to use
> output.fmtKeyValFill(), it is not in the API.
I did this earlier, because couldn't find API func to do this.

What now we have to fill this ?

Comment 6 Ales Kozumplik 2014-08-08 11:18:43 UTC
(In reply to Igor Gnatenko from comment #5)
> (In reply to Ales Kozumplik from comment #3)
> > Moving to the COPR guys. Miroslav, plugins are not supposed to use
> > output.fmtKeyValFill(), it is not in the API.
> I did this earlier, because couldn't find API func to do this.
> 

The correct approach is to open a bug against DNF describing the use case that you want the API to cover.

Comment 7 Igor Gnatenko 2014-08-08 11:29:00 UTC
Filled.

Comment 8 Honza Silhan 2014-08-15 09:05:32 UTC
*** Bug 1130391 has been marked as a duplicate of this bug. ***

Comment 9 Branislav Blaškovič 2014-08-19 12:11:46 UTC
I probably hit this too with dnf-plugins-core-0.1.1-3.fc20.noarch:

    $ sudo dnf copr search nitrate
    [sudo] password for bblaskov:
    ================================================== Matched: nitrate ===================================================
    Traceback (most recent call last):
      File "/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 200, in user_main
        errcode = main(args)
      File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 83, in main
        return _main(base, args)
      File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 133, in _main
        cli.run()
      File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1171, in run
        return self.command.run(self.base.extcmds)
      File "/usr/lib/python2.7/site-packages/dnf-plugins/copr.py", line 153, in run
        msg = self.base.output.fmtKeyValFill(msg, desc)
      File "/usr/lib/python2.7/site-packages/dnf/cli/output.py", line 704, in fmtKeyValFill
        keylen = exact_width(key)
      File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in exact_width
        return sum(_exact_width_char(c) for c in msg)
      File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 164, in <genexpr>
        return sum(_exact_width_char(c) for c in msg)
      File "/usr/lib/python2.7/site-packages/dnf/i18n.py", line 138, in _exact_width_char
        return 2 if unicodedata.east_asian_width(uchar) in ('W', 'F', 'A') else 1
    TypeError: must be unicode, not str

Comment 10 Adam Samalik 2014-08-19 14:32:09 UTC
I have made an easy workaround which fixes that:

https://asamalik.fedorapeople.org/dnf_copr_search_workaround.patch

Comment 11 Honza Silhan 2014-08-19 15:11:36 UTC
Adam, thanks for taking action but this patch could not work in Python 3. I made more complex patch that cover that but I need to test it.

Comment 12 Miroslav Suchý 2014-08-19 15:21:29 UTC
Adam I took your patch, but instead used dnf.i18n.ucd() (which is documented in API) and the value is not needed to encode. So I minimalized it.

Commited as b3be04f.

Comment 13 Guy Streeter 2014-08-21 14:38:05 UTC
Another user experienced a similar problem:

sudo dnf copr search python

reporter:       libreport-2.2.3
cmdline:        /usr/bin/python -OO /bin/dnf copr search python3
dso_list:       dnf-plugins-core-0.1.1-3.fc20.noarch
executable:     /bin/dnf
kernel:         3.15.8-200.mst.fc20.x86_64
package:        dnf-0.5.4-2.fc20
reason:         i18n.py:138:_exact_width_char:TypeError: must be unicode, not str
runlevel:       N 5
type:           Python
uid:            0

Comment 14 Honza Silhan 2014-08-22 08:39:29 UTC
*** Bug 1132109 has been marked as a duplicate of this bug. ***

Comment 15 Fedora Update System 2014-09-05 10:42:53 UTC
dnf-plugins-core-0.1.3-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/dnf-plugins-core-0.1.3-1.fc21

Comment 16 Fedora Update System 2014-09-06 00:57:26 UTC
Package dnf-plugins-core-0.1.3-1.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.1.3-1.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-10134/dnf-plugins-core-0.1.3-1.fc21
then log in and leave karma (feedback).

Comment 17 Branislav Blaškovič 2014-09-08 07:00:50 UTC
Why is this build for fc21 when this bug has target version set to fc20?

Will it be backported to fc20?

Comment 18 Miroslav Suchý 2014-09-08 07:25:35 UTC
The version field have semantics (you get this help, when you click on the label):
 This field is used to denote the version of the product that the problem is found in. 

So it was found in F20. But maintainers decided to fix it in F21. This is quite common to non-fatal bugs. Of course, you can always ask maintainers (akozumpl or jsilhan) to backport it to F20.

Comment 19 Branislav Blaškovič 2014-09-08 07:45:10 UTC
You are right. I will contact maintainers to submit patch to fc20 as well.
Thank you.

Comment 20 Fedora Update System 2014-09-23 04:29:23 UTC
dnf-plugins-core-0.1.3-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 21 Honza Silhan 2014-10-24 07:50:57 UTC
*** Bug 1154801 has been marked as a duplicate of this bug. ***

Comment 22 Honza Horak 2014-10-30 20:44:55 UTC
Could this be fixed in F20, please?

Comment 23 Fedora Update System 2014-11-05 18:29:34 UTC
dnf-plugins-core-0.1.1-4.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/dnf-plugins-core-0.1.1-4.fc20

Comment 24 lnie 2014-11-06 06:02:53 UTC
dnf-plugins-core-0.1.1-4.fc20 works

Comment 25 Fedora Update System 2014-11-10 06:13:28 UTC
dnf-plugins-core-0.1.1-4.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.